mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 08:59:28 +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 *ProjectManager::OpenProject(
|
||||||
AudacityProject *pProject, const FilePath &fileNameArg, bool addtohistory)
|
AudacityProject *pProject, const FilePath &fileNameArg, bool addtohistory)
|
||||||
{
|
{
|
||||||
|
bool success = false;
|
||||||
AudacityProject *pNewProject = nullptr;
|
AudacityProject *pNewProject = nullptr;
|
||||||
if ( ! pProject )
|
if ( ! pProject )
|
||||||
pProject = pNewProject = New();
|
pProject = pNewProject = New();
|
||||||
auto cleanup = finally( [&] {
|
auto cleanup = finally( [&] {
|
||||||
if ( pNewProject )
|
if ( pNewProject )
|
||||||
GetProjectFrame( *pNewProject ).Close(true);
|
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 );
|
ProjectFileManager::Get( *pProject ).OpenFile( fileNameArg, addtohistory );
|
||||||
|
|
||||||
|
// The above didn't throw, so change what finally will do
|
||||||
|
success = true;
|
||||||
pNewProject = nullptr;
|
pNewProject = nullptr;
|
||||||
|
|
||||||
auto &projectFileIO = ProjectFileIO::Get( *pProject );
|
auto &projectFileIO = ProjectFileIO::Get( *pProject );
|
||||||
if( projectFileIO.IsRecovered() ) {
|
if( projectFileIO.IsRecovered() ) {
|
||||||
auto &window = ProjectWindow::Get( *pProject );
|
auto &window = ProjectWindow::Get( *pProject );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user