diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 1da985a03e..8543c9270c 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -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 diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index ef9f8de931..84b94b6884 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -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(); } diff --git a/eeschema/tools/symbol_editor_control.cpp b/eeschema/tools/symbol_editor_control.cpp index 3c687f967b..a4ba66404f 100644 --- a/eeschema/tools/symbol_editor_control.cpp +++ b/eeschema/tools/symbol_editor_control.cpp @@ -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; diff --git a/include/kiway_holder.h b/include/kiway_holder.h index 73af0a2a22..ff91afbde6 100644 --- a/include/kiway_holder.h +++ b/include/kiway_holder.h @@ -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. */ diff --git a/kicad/import_project.cpp b/kicad/import_project.cpp index 36632b8ace..4a6bab0c40 100644 --- a/kicad/import_project.cpp +++ b/kicad/import_project.cpp @@ -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 ); diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index e9eec1ae3a..d267dd9784 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -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(); }