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
e36491f231
commit
82167a7c96
|
@ -945,6 +945,12 @@ void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event )
|
|||
fn.SetExt( PcbFileExtension );
|
||||
|
||||
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() ) );
|
||||
}
|
||||
|
||||
|
@ -1137,6 +1143,12 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event )
|
|||
if( !frame )
|
||||
{
|
||||
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() ) );
|
||||
}
|
||||
|
||||
|
@ -1174,6 +1186,12 @@ void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event )
|
|||
if( !player )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -1549,15 +1549,20 @@ void PCB_EDIT_FRAME::ToPlotter( int aID )
|
|||
}
|
||||
|
||||
|
||||
bool PCB_EDIT_FRAME::TestStandalone()
|
||||
int PCB_EDIT_FRAME::TestStandalone()
|
||||
{
|
||||
if( Kiface().IsSingle() )
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
// Update PCB requires a netlist. Therefore the schematic editor must be running
|
||||
// If this is not the case, open the schematic editor
|
||||
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() )
|
||||
{
|
||||
wxFileName fn( Prj().GetProjectPath(), Prj().GetProjectName(),
|
||||
|
@ -1572,7 +1577,7 @@ bool PCB_EDIT_FRAME::TestStandalone()
|
|||
if( !fn.FileExists() )
|
||||
{
|
||||
DisplayError( this, _( "The schematic for this board cannot be found." ) );
|
||||
return false;
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1586,14 +1591,14 @@ bool PCB_EDIT_FRAME::TestStandalone()
|
|||
Raise();
|
||||
}
|
||||
|
||||
return true; //Success!
|
||||
return 1; //Success!
|
||||
}
|
||||
|
||||
|
||||
bool PCB_EDIT_FRAME::FetchNetlistFromSchematic( NETLIST& aNetlist,
|
||||
const wxString& aAnnotateMessage )
|
||||
{
|
||||
if( !TestStandalone() )
|
||||
if( TestStandalone() == 0 )
|
||||
{
|
||||
DisplayErrorMessage( this, _( "Cannot update the PCB because PCB editor is opened in "
|
||||
"stand-alone mode. In order to create or update PCBs from "
|
||||
|
@ -1602,6 +1607,9 @@ bool PCB_EDIT_FRAME::FetchNetlistFromSchematic( NETLIST& aNetlist,
|
|||
return false; // Not in standalone mode
|
||||
}
|
||||
|
||||
if( TestStandalone() < 0 ) // Problem with Eeschema or the schematic
|
||||
return false;
|
||||
|
||||
Raise(); // Show
|
||||
|
||||
std::string payload( aAnnotateMessage );
|
||||
|
@ -1691,6 +1699,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)
|
||||
// but no project loaded.
|
||||
{
|
||||
|
|
|
@ -611,9 +611,11 @@ public:
|
|||
/**
|
||||
* 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.
|
||||
|
|
Loading…
Reference in New Issue