[trunk] [branch 1.2] Need to clean up use of exeptions (throw)
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
Same goes for the abort() calls , of which there are about 30 in the branch.
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
Incase you didn't know, jorgk3: Project issue numbers (e.g. [#12345]) turn into links automatically.
:)
Seems the linked to issues are closed since long, #15059: Embedded pictures when creating part cause crash, #14748: [trunk] we need a Qt message handler to catch crashes originating from Q_ASSERT more quickly, #14748: [trunk] we need a Qt message handler to catch crashes originating from Q_ASSERT more quickly
Does it relate to #271185: Scores corrupted beyond repair, containing nothing but zeros?