1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-04-30 15:49:41 +02:00

Fix crash on exit, which could be seen at least on Mac, if you...

... Start Audacity; generate some noise; shift clip with Time-Shift tool;
command+Q to exit; say No to save changes.

The scope of a GuardedCall needs to be expanded, because Conn() can throw,
so that no exceptions escape the destructor of SqliteSampleBlock.

But now there is an error dialog on exit instead of a crash.
This commit is contained in:
Paul Licameli 2020-09-14 15:07:32 -04:00
parent c5c7a6d08a
commit cbd21c5fff

View File

@ -315,15 +315,17 @@ SqliteSampleBlock::~SqliteSampleBlock()
} }
// See ProjectFileIO::Bypass() for a description of mIO.mBypass // See ProjectFileIO::Bypass() for a description of mIO.mBypass
if (!mLocked && !Conn()->ShouldBypass()) GuardedCall( [this]{
{ if (!mLocked && !Conn()->ShouldBypass())
// In case Delete throws, don't let an exception escape a destructor, {
// but we can still enqueue the delayed handler so that an error message // In case Delete throws, don't let an exception escape a destructor,
// is presented to the user. // but we can still enqueue the delayed handler so that an error message
// The failure in this case may be a less harmful waste of space in the // is presented to the user.
// database, which should not cause aborting of the attempted edit. // The failure in this case may be a less harmful waste of space in the
GuardedCall( [this]{ Delete(); } ); // database, which should not cause aborting of the attempted edit.
} Delete();
}
} );
} }
DBConnection *SqliteSampleBlock::Conn() const DBConnection *SqliteSampleBlock::Conn() const