7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 14:41:42 +00:00

Fix schematic setup dialog reopens instead of activating if already open

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18757
This commit is contained in:
Dhineshkumar S 2024-11-19 21:06:40 +00:00 committed by Seth Hillbrand
parent 120b06f916
commit dc5550c875
6 changed files with 42 additions and 9 deletions

View File

@ -103,6 +103,21 @@ void SCH_EDIT_FRAME::LoadDrawingSheet()
void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage )
{
static std::mutex dialogMutex; // Local static mutex
std::unique_lock<std::mutex> dialogLock( dialogMutex, std::try_to_lock );
// One dialog at a time.
if( !dialogLock.owns_lock() )
{
if( m_schematicSetupDialog && m_schematicSetupDialog->IsShown() )
{
m_schematicSetupDialog->Raise(); // Brings the existing dialog to the front
}
return;
}
SCH_SCREENS screens( Schematic().Root() );
std::vector<std::shared_ptr<BUS_ALIAS>> oldAliases;
@ -116,6 +131,9 @@ void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage )
if( !aInitialPage.IsEmpty() )
dlg.SetInitialPage( aInitialPage, wxEmptyString );
// Assign dlg to the m_schematicSetupDialog pointer to track its status.
m_schematicSetupDialog = &dlg;
// TODO: is QuasiModal required here?
if( dlg.ShowQuasiModal() == wxID_OK )
@ -154,6 +172,9 @@ void SCH_EDIT_FRAME::ShowSchematicSetupDialog( const wxString& aInitialPage )
RefreshOperatingPointDisplay();
GetCanvas()->Refresh();
}
// Reset m_schematicSetupDialog after the dialog is closed
m_schematicSetupDialog = nullptr;
}

View File

@ -65,6 +65,7 @@ class DIALOG_SCH_FIND;
class RESCUER;
class HIERARCHY_PANE;
class API_HANDLER_SCH;
class DIALOG_SCHEMATIC_SETUP;
/// Schematic search type used by the socket link with Pcbnew
@ -1097,6 +1098,7 @@ private:
DIALOG_BOOK_REPORTER* m_diffSymbolDialog;
HIERARCHY_PANE* m_hierarchy;
DIALOG_SYMBOL_FIELDS_TABLE* m_symbolFieldsTableDialog;
DIALOG_SCHEMATIC_SETUP* m_schematicSetupDialog;
wxTreeCtrl* m_netNavigator;

View File

@ -48,9 +48,6 @@
#include "dialog_board_setup.h"
std::mutex DIALOG_BOARD_SETUP::g_Mutex;
#define RESOLVE_PAGE( T, pageIndex ) static_cast<T*>( m_treebook->ResolvePage( pageIndex ) )
DIALOG_BOARD_SETUP::DIALOG_BOARD_SETUP( PCB_EDIT_FRAME* aFrame ) :

View File

@ -21,7 +21,6 @@
#ifndef KICAD_DIALOG_BOARD_SETUP_H
#define KICAD_DIALOG_BOARD_SETUP_H
#include <mutex>
#include <widgets/paged_dialog.h>
#include "panel_setup_formatting.h"
@ -55,9 +54,6 @@ protected:
PANEL_SETUP_BOARD_FINISH* m_boardFinish;
PANEL_SETUP_BOARD_STACKUP* m_physicalStackup;
public:
static std::mutex g_Mutex; // Mutex to prevent multiple windows opening
private:
size_t m_currentPage; // the current page index
size_t m_layersPage;

View File

@ -1285,11 +1285,20 @@ 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 );
static std::mutex dialogMutex; // Local static mutex
// One DIALOG_BOARD_SETUP dialog at a time.
std::unique_lock<std::mutex> dialogLock( dialogMutex, std::try_to_lock );
// One dialog at a time.
if( !dialogLock.owns_lock() )
{
if( m_boardSetupDlg && m_boardSetupDlg->IsShown() )
{
m_boardSetupDlg->Raise(); // Brings the existing dialog to the front
}
return;
}
// Make sure everything's up-to-date
GetBoard()->BuildListOfNets();
@ -1298,6 +1307,9 @@ void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
if( !aInitialPage.IsEmpty() )
dlg.SetInitialPage( aInitialPage, wxEmptyString );
// Assign dlg to the m_boardSetupDlg pointer to track its status.
m_boardSetupDlg = &dlg;
// QuasiModal required for Scintilla auto-complete
if( dlg.ShowQuasiModal() == wxID_OK )
@ -1370,6 +1382,9 @@ void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage )
}
GetCanvas()->SetFocus();
// Reset m_boardSetupDlg after the dialog is closed
m_boardSetupDlg = nullptr;
}

View File

@ -56,6 +56,7 @@ class FP_LIB_TABLE;
class BOARD_NETLIST_UPDATER;
class ACTION_MENU;
class TOOL_ACTION;
class DIALOG_BOARD_SETUP;
#ifdef KICAD_IPC_API
class KICAD_API_SERVER;
@ -874,6 +875,7 @@ private:
DIALOG_BOOK_REPORTER* m_inspectClearanceDlg;
DIALOG_BOOK_REPORTER* m_inspectConstraintsDlg;
DIALOG_BOOK_REPORTER* m_footprintDiffDlg;
DIALOG_BOARD_SETUP* m_boardSetupDlg;
const std::map<std::string, UTF8>* m_importProperties; // Properties used for non-KiCad import.