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* plugin = SCH_IO_MGR::FindPlugin( schFileType );
|
||||||
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( plugin );
|
SCH_PLUGIN::SCH_PLUGIN_RELEASER pi( plugin );
|
||||||
|
|
||||||
|
bool failedLoad = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Schematic().SetRoot( pi->Load( fullFileName, &Schematic() ) );
|
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 )
|
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
|
// Do not leave g_RootSheet == NULL because it is expected to be
|
||||||
// a valid sheet. Therefore create a dummy empty root sheet and screen.
|
// a valid sheet. Therefore create a dummy empty root sheet and screen.
|
||||||
CreateScreens();
|
CreateScreens();
|
||||||
m_toolManager->RunAction( ACTIONS::zoomFitScreen, true );
|
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 );
|
msg.Printf( _( "Failed to load \"%s\"" ), fullFileName );
|
||||||
SetMsgPanel( wxEmptyString, msg );
|
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
|
// This will rename the file if there is an autosave and the user want to recover
|
||||||
CheckForAutoSaveFile( fullFileName );
|
CheckForAutoSaveFile( fullFileName );
|
||||||
|
|
||||||
|
bool failedLoad = false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PROPERTIES props;
|
PROPERTIES props;
|
||||||
|
@ -703,6 +705,18 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
|
||||||
DisplayErrorMessage( this, msg, ioe.What() );
|
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
|
// We didn't create a new blank board above, so do that now
|
||||||
Clear_Pcb( false );
|
Clear_Pcb( false );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue