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:
parent
5e21f526b4
commit
38e0a982ce
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user