Protect the Kiway dereference
Also find a few more places where we are reaching into a new frame to perform actions that need to have dialogs closed. Running actions should also wait for the next cycle rather than being immediately executed when we are calling into a new frame. This allow for the cleanup actions onClose() to happen prior to the next action starting Fixes https://gitlab.com/kicad/code/kicad/issues/11891
This commit is contained in:
parent
00c7b64b13
commit
93fb00d815
|
@ -123,7 +123,8 @@ DIALOG_SHIM::DIALOG_SHIM( wxWindow* aParent, wxWindowID id, const wxString& titl
|
|||
if( kiwayHolder )
|
||||
SetKiway( this, &kiwayHolder->Kiway() );
|
||||
|
||||
Kiway().SetBlockingDialog( this );
|
||||
if( HasKiway() )
|
||||
Kiway().SetBlockingDialog( this );
|
||||
|
||||
Bind( wxEVT_CLOSE_WINDOW, &DIALOG_SHIM::OnCloseWindow, this );
|
||||
Bind( wxEVT_BUTTON, &DIALOG_SHIM::OnButton, this );
|
||||
|
@ -146,7 +147,8 @@ DIALOG_SHIM::~DIALOG_SHIM()
|
|||
if( IsQuasiModal() )
|
||||
EndQuasiModal( wxID_CANCEL );
|
||||
|
||||
Kiway().SetBlockingDialog( nullptr );
|
||||
if( HasKiway() )
|
||||
Kiway().SetBlockingDialog( nullptr );
|
||||
|
||||
if( m_qmodal_parent_disabler )
|
||||
delete m_qmodal_parent_disabler; // usually NULL by now
|
||||
|
|
|
@ -1533,6 +1533,11 @@ void SIM_PLOT_FRAME::onProbe( wxCommandEvent& event )
|
|||
if( m_schematicFrame == nullptr )
|
||||
return;
|
||||
|
||||
wxWindow* blocking_dialog = m_schematicFrame->Kiway().GetBlockingDialog();
|
||||
|
||||
if( blocking_dialog )
|
||||
blocking_dialog->Close( true );
|
||||
|
||||
m_schematicFrame->GetToolManager()->RunAction( EE_ACTIONS::simProbe );
|
||||
m_schematicFrame->Raise();
|
||||
}
|
||||
|
@ -1545,6 +1550,11 @@ void SIM_PLOT_FRAME::onTune( wxCommandEvent& event )
|
|||
if( m_schematicFrame == nullptr )
|
||||
return;
|
||||
|
||||
wxWindow* blocking_dialog = m_schematicFrame->Kiway().GetBlockingDialog();
|
||||
|
||||
if( blocking_dialog )
|
||||
blocking_dialog->Close( true );
|
||||
|
||||
m_schematicFrame->GetToolManager()->RunAction( EE_ACTIONS::simTune );
|
||||
m_schematicFrame->Raise();
|
||||
}
|
||||
|
|
|
@ -626,7 +626,7 @@ int SYMBOL_EDITOR_CONTROL::AddSymbolToSchematic( const TOOL_EVENT& aEvent )
|
|||
symbol->AutoplaceFields( /* aScreen */ nullptr, /* aManual */ false );
|
||||
|
||||
schframe->Raise();
|
||||
schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, true, symbol );
|
||||
schframe->GetToolManager()->RunAction( EE_ACTIONS::placeSymbol, false, symbol );
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -56,6 +56,15 @@ public:
|
|||
return *m_kiway;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safety check before asking for the Kiway reference
|
||||
* @return true if kiway is non-null
|
||||
*/
|
||||
bool HasKiway() const
|
||||
{
|
||||
return m_kiway != nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reference to the #PROJECT associated with this #KIWAY.
|
||||
*/
|
||||
|
|
|
@ -183,6 +183,11 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( const wxString& aWindowTitle,
|
|||
{
|
||||
KIWAY_PLAYER* schframe = Kiway().Player( FRAME_SCH, true );
|
||||
|
||||
wxWindow* blocking_dialog = schframe->Kiway().GetBlockingDialog();
|
||||
|
||||
if( blocking_dialog )
|
||||
blocking_dialog->Close( true );
|
||||
|
||||
packet = StrPrintf( "%d\n%s", aSchFileType, TO_UTF8( schCopy.GetFullPath() ) );
|
||||
schframe->Kiway().ExpressMail( FRAME_SCH, MAIL_IMPORT_FILE, packet, this );
|
||||
|
||||
|
@ -203,6 +208,11 @@ void KICAD_MANAGER_FRAME::ImportNonKiCadProject( const wxString& aWindowTitle,
|
|||
{
|
||||
KIWAY_PLAYER* pcbframe = Kiway().Player( FRAME_PCB_EDITOR, true );
|
||||
|
||||
wxWindow* blocking_dialog = pcbframe->Kiway().GetBlockingDialog();
|
||||
|
||||
if( blocking_dialog )
|
||||
blocking_dialog->Close( true );
|
||||
|
||||
if( !pcbframe->IsVisible() )
|
||||
pcbframe->Show( true );
|
||||
|
||||
|
|
|
@ -798,6 +798,11 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
|
|||
return;
|
||||
}
|
||||
|
||||
wxWindow* blocking_dialog = pcbframe->Kiway().GetBlockingDialog();
|
||||
|
||||
if( blocking_dialog )
|
||||
blocking_dialog->Close( true );
|
||||
|
||||
toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||
BOARD_COMMIT commit( pcbframe );
|
||||
|
||||
|
@ -836,7 +841,7 @@ void FOOTPRINT_VIEWER_FRAME::AddFootprintToPCB( wxCommandEvent& aEvent )
|
|||
commit.Push( wxT( "Insert footprint" ) );
|
||||
|
||||
pcbframe->Raise();
|
||||
toolMgr->RunAction( PCB_ACTIONS::placeFootprint, true, newFootprint );
|
||||
toolMgr->RunAction( PCB_ACTIONS::placeFootprint, false, newFootprint );
|
||||
|
||||
newFootprint->ClearFlags();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue