1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-01 00:19:27 +02:00

Bug2772: Crash after failed open of corrupt project

This commit is contained in:
Paul Licameli 2021-05-01 12:46:27 -04:00
parent 5e21f526b4
commit 38e0a982ce

View File

@ -901,15 +901,25 @@ void ProjectManager::OpenFiles(AudacityProject *proj)
AudacityProject *ProjectManager::OpenProject(
AudacityProject *pProject, const FilePath &fileNameArg, bool addtohistory)
{
bool success = false;
AudacityProject *pNewProject = nullptr;
if ( ! pProject )
pProject = pNewProject = New();
auto cleanup = finally( [&] {
if( pNewProject )
if ( pNewProject )
GetProjectFrame( *pNewProject ).Close(true);
else if ( !success )
// Ensure that it happens here: don't wait for the application level
// exception handler, because the exception may be intercepted
ProjectHistory::Get(*pProject).RollbackState();
// Any exception now continues propagating
} );
ProjectFileManager::Get( *pProject ).OpenFile( fileNameArg, addtohistory );
// The above didn't throw, so change what finally will do
success = true;
pNewProject = nullptr;
auto &projectFileIO = ProjectFileIO::Get( *pProject );
if( projectFileIO.IsRecovered() ) {
auto &window = ProjectWindow::Get( *pProject );