Prevent PCB Editor from opening multiple board_setup
ShowBoardSetup can be called multiple times from multiple locations, resulting in duplicate board setup dialog boxes. This is confusing and should be prevented. We use the established patter from the symbol picker to ensure that only one copy of the dialog is ever opened at a time
This commit is contained in:
parent
061e423b1f
commit
7695d510d6
|
@ -45,6 +45,8 @@
|
|||
|
||||
#include <wx/treebook.h>
|
||||
|
||||
std::mutex DIALOG_BOARD_SETUP::g_Mutex;
|
||||
|
||||
|
||||
DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :
|
||||
PAGED_DIALOG( aFrame, _( "Board Setup" ), false,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef KICAD_DIALOG_BOARD_SETUP_H
|
||||
#define KICAD_DIALOG_BOARD_SETUP_H
|
||||
|
||||
#include <mutex>
|
||||
#include <widgets/paged_dialog.h>
|
||||
#include "panel_setup_formatting.h"
|
||||
|
||||
|
@ -64,6 +65,9 @@ protected:
|
|||
PANEL_SETUP_SEVERITIES* m_severities;
|
||||
PANEL_TEXT_VARIABLES* m_textVars;
|
||||
|
||||
public:
|
||||
static std::mutex g_Mutex; // Mutex to prevent multiple windows opening
|
||||
|
||||
private:
|
||||
int m_currentPage; // the current page index
|
||||
int m_physicalStackupPage; // the page index of the PANEL_SETUP_BOARD_STACKUP page
|
||||
|
|
|
@ -1192,6 +1192,12 @@ void PCB_EDIT_FRAME::ActivateGalCanvas()
|
|||
|
||||
void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
|
||||
{
|
||||
std::unique_lock<std::mutex> dialogLock( DIALOG_BOARD_SETUP::g_Mutex, std::try_to_lock );
|
||||
|
||||
// One DIALOG_BOARD_SETUP dialog at a time.
|
||||
if( !dialogLock.owns_lock() )
|
||||
return;
|
||||
|
||||
// Make sure everything's up-to-date
|
||||
GetBoard()->BuildListOfNets();
|
||||
|
||||
|
|
Loading…
Reference in New Issue