Avoid crashes when, for some reason, a dll cannot be loaded.
In this case a null pointer was returned by the internal code. This pointer is now tested against nullptr to avoid the application crashing. Fixes #12080 https://gitlab.com/kicad/code/kicad/issues/12080
This commit is contained in:
parent
38b75db12c
commit
a5b676fa0e
|
@ -869,6 +869,12 @@ void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
|
||||||
fn.SetExt( PcbFileExtension );
|
fn.SetExt( PcbFileExtension );
|
||||||
|
|
||||||
frame = Kiway().Player( FRAME_PCB_EDITOR, true );
|
frame = Kiway().Player( FRAME_PCB_EDITOR, true );
|
||||||
|
|
||||||
|
// If Kiway() cannot create the Pcbnew frame, it shows a error message, and
|
||||||
|
// frame is null
|
||||||
|
if( !frame )
|
||||||
|
return;
|
||||||
|
|
||||||
frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,6 +1049,12 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
|
||||||
if( !frame )
|
if( !frame )
|
||||||
{
|
{
|
||||||
frame = Kiway().Player( FRAME_PCB_EDITOR, true );
|
frame = Kiway().Player( FRAME_PCB_EDITOR, true );
|
||||||
|
|
||||||
|
// frame can be null if Cvpcb cannot be run. No need to show a warning
|
||||||
|
// Kiway() generates the error messages
|
||||||
|
if( !frame )
|
||||||
|
return;
|
||||||
|
|
||||||
frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
|
frame->OpenProjectFiles( std::vector<wxString>( 1, boardfn.GetFullPath() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1080,6 +1092,12 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
|
||||||
if( !player )
|
if( !player )
|
||||||
{
|
{
|
||||||
player = Kiway().Player( FRAME_CVPCB, true );
|
player = Kiway().Player( FRAME_CVPCB, true );
|
||||||
|
|
||||||
|
// player can be null if Cvpcb cannot be run. No need to show a warning
|
||||||
|
// Kiway() generates the error messages
|
||||||
|
if( !player )
|
||||||
|
return;
|
||||||
|
|
||||||
player->Show( true );
|
player->Show( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1463,15 +1463,20 @@ void PCB_EDIT_FRAME::ToPlotter( int aID )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PCB_EDIT_FRAME::TestStandalone()
|
int PCB_EDIT_FRAME::TestStandalone()
|
||||||
{
|
{
|
||||||
if( Kiface().IsSingle() )
|
if( Kiface().IsSingle() )
|
||||||
return false;
|
return 0;
|
||||||
|
|
||||||
// Update PCB requires a netlist. Therefore the schematic editor must be running
|
// Update PCB requires a netlist. Therefore the schematic editor must be running
|
||||||
// If this is not the case, open the schematic editor
|
// If this is not the case, open the schematic editor
|
||||||
KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
|
KIWAY_PLAYER* frame = Kiway().Player( FRAME_SCH, true );
|
||||||
|
|
||||||
|
// If Kiway() cannot create the eeschema frame, it shows a error message, and
|
||||||
|
// frame is null
|
||||||
|
if( !frame )
|
||||||
|
return -1;
|
||||||
|
|
||||||
if( !frame->IsShown() )
|
if( !frame->IsShown() )
|
||||||
{
|
{
|
||||||
wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
|
wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
|
||||||
|
@ -1486,7 +1491,7 @@ bool PCB_EDIT_FRAME::TestStandalone()
|
||||||
if( !fn.FileExists() )
|
if( !fn.FileExists() )
|
||||||
{
|
{
|
||||||
DisplayError( this, _( "The schematic for this board cannot be found." ) );
|
DisplayError( this, _( "The schematic for this board cannot be found." ) );
|
||||||
return false;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1500,14 +1505,14 @@ bool PCB_EDIT_FRAME::TestStandalone()
|
||||||
Raise();
|
Raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true; //Success!
|
return 1; //Success!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PCB_EDIT_FRAME::FetchNetlistFromSchematic( NETLIST& aNetlist,
|
bool PCB_EDIT_FRAME::FetchNetlistFromSchematic( NETLIST& aNetlist,
|
||||||
const wxString& aAnnotateMessage )
|
const wxString& aAnnotateMessage )
|
||||||
{
|
{
|
||||||
if( !TestStandalone() )
|
if( TestStandalone() == 0 )
|
||||||
{
|
{
|
||||||
DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
|
DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
|
||||||
"stand-alone mode. In order to create or update PCBs from "
|
"stand-alone mode. In order to create or update PCBs from "
|
||||||
|
@ -1516,6 +1521,9 @@ bool PCB_EDIT_FRAME::FetchNetlistFromSchematic( NETLIST& aNetlist,
|
||||||
return false; // Not in standalone mode
|
return false; // Not in standalone mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( TestStandalone() < 0 ) // Problem with Eeschema or the schematic
|
||||||
|
return false;
|
||||||
|
|
||||||
Raise(); // Show
|
Raise(); // Show
|
||||||
|
|
||||||
std::string payload( aAnnotateMessage );
|
std::string payload( aAnnotateMessage );
|
||||||
|
@ -1605,6 +1613,11 @@ void PCB_EDIT_FRAME::RunEeschema()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If Kiway() cannot create the eeschema frame, it shows a error message, and
|
||||||
|
// frame is null
|
||||||
|
if( !frame )
|
||||||
|
return;
|
||||||
|
|
||||||
if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
|
if( !frame->IsShown() ) // the frame exists, (created by the dialog field editor)
|
||||||
// but no project loaded.
|
// but no project loaded.
|
||||||
{
|
{
|
||||||
|
|
|
@ -592,9 +592,11 @@ public:
|
||||||
/**
|
/**
|
||||||
* Test if standalone mode.
|
* Test if standalone mode.
|
||||||
*
|
*
|
||||||
* @return true if in standalone, opens Eeschema, and opens the schematic for this project
|
* @return 0 if in standalone, -1 if Eeschema cannot be opened,
|
||||||
|
* -2 if the schematic cannot be opened and 1 if OK.
|
||||||
|
* If OK, opens Eeschema, and opens the schematic for this project
|
||||||
*/
|
*/
|
||||||
bool TestStandalone( void );
|
int TestStandalone( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read a netlist from a file into a #NETLIST object.
|
* Read a netlist from a file into a #NETLIST object.
|
||||||
|
|
Loading…
Reference in New Issue