Try to catch memory allocation errors in pcbnew and eeschema
This commit is contained in:
parent
850a22c3ae
commit
18ff8ea4a0
|
@ -393,6 +393,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& 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<wxString>& 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 );
|
||||
|
||||
|
|
|
@ -669,6 +669,8 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& 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<wxString>& 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 );
|
||||
|
||||
|
|
Loading…
Reference in New Issue