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
1 changed files with 11 additions and 9 deletions

View File

@ -315,15 +315,17 @@ SqliteSampleBlock::~SqliteSampleBlock()
}
// See ProjectFileIO::Bypass() for a description of mIO.mBypass
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
// is presented to the user.
// The failure in this case may be a less harmful waste of space in the
// database, which should not cause aborting of the attempted edit.
GuardedCall( [this]{ Delete(); } );
}
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
// is presented to the user.
// The failure in this case may be a less harmful waste of space in the
// database, which should not cause aborting of the attempted edit.
Delete();
}
} );
}
DBConnection *SqliteSampleBlock::Conn() const