[trunk] [branch 1.2] Need to clean up use of exeptions (throw)

• Mar 1, 2012 - 17:28
Type
Functional
Severity
S4 - Minor
Status
active
Project

The trunk uses "throw" 9 times in libmscore and a few times in mscore.
These uses need to be reviewed and cleaned up. Werner's coding conventions say (quote): "Don’t use exceptions".

For example MuseScore::autoSaveTimerTimeout() calls saveCompressedFile() is called which throws. Sadly no one catches, so the application crashes.
musescore.cpp:

void MuseScore::autoSaveTimerTimeout()
{
bool sessionChanged = false;
foreach(Score* s, scoreList) {
if (s->autosaveDirty()) {
QString tmp = s->tmpName();
if (!tmp.isEmpty()) {
QFileInfo fi(tmp);
// TODO: cannot catch exeption here:
cs->saveCompressedFile(fi, false);

In the branch saveCompressedFile() fails if for example an embedded image cannot be found (see issue #15059: Embedded pictures when creating part cause crash ).


Comments

Title [trunk] [branch 1.2] Need to clean up use of exeptions (throw) and aborts [trunk] [branch 1.2] Need to clean up use of exeptions (throw)

I'm glad someone is agreeing. However, we won't do it in the branch anymore, but we should do it in the trunk.

There is already an issue about the abort()'s:
issue #14764: [trunk] Need to remove all direct uses of abort(). qFatal should be used instead.

Sadly Werner thinks they are OK to use, see his comment #5. Since I don't have checkin rights I can't go around replacing the aborts.

If we used qFatal, we could easily trap all aborts in the message handler, which did get accepted:
issue #14748: [trunk] we need a Qt message handler to catch crashes originating from Q_ASSERT more quickly