diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index a4943d9bf4..a50fe07604 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -393,6 +393,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in SCH_PLUGIN* plugin = SCH_IO_MGR::FindPlugin( schFileType ); SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( plugin ); + bool failedLoad = false; try { Schematic().SetRoot( pi->Load( fullFileName, &Schematic() ) ); @@ -407,16 +408,28 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in } } catch( const IO_ERROR& ioe ) + { + msg.Printf( _( "Error loading schematic file \"%s\"" ), + fullFileName); + DisplayErrorMessage( this, msg, ioe.What() ); + + failedLoad = true; + } + catch( const std::bad_alloc& ) + { + msg.Printf( _( "Memory exhausted loading schematic file \"%s\"" ), fullFileName ); + DisplayErrorMessage( this, msg ); + + failedLoad = true; + } + + if( failedLoad ) { // Do not leave g_RootSheet == NULL because it is expected to be // a valid sheet. Therefore create a dummy empty root sheet and screen. CreateScreens(); m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); - msg.Printf( _( "Error loading schematic file \"%s\".\n%s" ), - fullFileName, ioe.What() ); - DisplayError( this, msg ); - msg.Printf( _( "Failed to load \"%s\"" ), fullFileName ); SetMsgPanel( wxEmptyString, msg ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 55177578a3..e559a771b1 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -669,6 +669,8 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in // This will rename the file if there is an autosave and the user want to recover CheckForAutoSaveFile( fullFileName ); + bool failedLoad = false; + try { PROPERTIES props; @@ -703,6 +705,18 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in DisplayErrorMessage( this, msg, ioe.What() ); } + failedLoad = true; + } + catch( const std::bad_alloc& ) + { + wxString msg = wxString::Format( _( "Memory exhausted loading board file:\n%s" ), fullFileName ); + DisplayErrorMessage( this, msg ); + + failedLoad = true; + } + + if( failedLoad ) + { // We didn't create a new blank board above, so do that now Clear_Pcb( false );