From f079c411189100409a88008f380aaa940b782119 Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sun, 8 Mar 2020 15:55:14 +0000 Subject: [PATCH] Prevent the board setup dialog from opening when DRC is open The board setup dialog controls DRC error visibility, so the two dialogs shouldn't be open at the same time to prevent data contention. Follow-up to https://gitlab.com/kicad/code/kicad/-/issues/4023 --- pcbnew/drc/drc.cpp | 9 +++++++++ pcbnew/drc/drc.h | 7 +++++++ pcbnew/menubar_pcb_editor.cpp | 19 +++++++++++++------ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/pcbnew/drc/drc.cpp b/pcbnew/drc/drc.cpp index aa3c4ae975..579185b79c 100644 --- a/pcbnew/drc/drc.cpp +++ b/pcbnew/drc/drc.cpp @@ -150,6 +150,15 @@ int DRC::ShowDRCDialog( const TOOL_EVENT& aEvent ) } +bool DRC::IsDRCDialogShown() +{ + if( m_drcDialog ) + return m_drcDialog->IsShown(); + + return false; +} + + void DRC::addMarkerToPcb( MARKER_PCB* aMarker ) { BOARD_COMMIT commit( m_pcbEditorFrame ); diff --git a/pcbnew/drc/drc.h b/pcbnew/drc/drc.h index b8ed63c51d..6f2b70a384 100644 --- a/pcbnew/drc/drc.h +++ b/pcbnew/drc/drc.h @@ -381,6 +381,13 @@ public: int ShowDRCDialog( const TOOL_EVENT& aEvent ); + /** + * Check to see if the DRC dialog is currently shown + * + * @return true if the dialog is shown + */ + bool IsDRCDialogShown(); + /** * Deletes this ui dialog box and zeros out its pointer to remember * the state of the dialog's existence. diff --git a/pcbnew/menubar_pcb_editor.cpp b/pcbnew/menubar_pcb_editor.cpp index d01f0c3afe..91491fc609 100644 --- a/pcbnew/menubar_pcb_editor.cpp +++ b/pcbnew/menubar_pcb_editor.cpp @@ -24,16 +24,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ -#include -#include "help_common_strings.h" -#include "pcbnew.h" -#include "pcbnew_id.h" +#include +#include #include +#include #include #include +#include +#include +#include #include -#include #include #include #include @@ -168,8 +169,14 @@ void PCB_EDIT_FRAME::ReCreateMenuBar() fileMenu->AddMenu( submenuFabOutputs, SELECTION_CONDITIONS::ShowAlways ); + auto enableBoardSetupCondition = [ this ] ( const SELECTION& sel ) { + if( DRC* tool = m_toolManager->GetTool() ) + return !tool->IsDRCDialogShown(); + + return true; + }; fileMenu->AddSeparator(); - fileMenu->AddItem( PCB_ACTIONS::boardSetup, SELECTION_CONDITIONS::ShowAlways ); + fileMenu->AddItem( PCB_ACTIONS::boardSetup, enableBoardSetupCondition ); fileMenu->AddSeparator(); fileMenu->AddItem( ACTIONS::pageSettings, SELECTION_CONDITIONS::ShowAlways );