DRC Rule Editor: Only reload when rules file changes on disk

This commit is contained in:
Damjan Prerad
2026-03-03 09:19:56 +01:00
parent bf25b6d7dd
commit db0744f369
2 changed files with 21 additions and 5 deletions
+19 -4
View File
@@ -97,15 +97,29 @@ void DRC_RULE_EDITOR_TOOL::ShowDRCRuleEditorDialog( wxWindow* aParent )
Activate();
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear );
// If the dialog was closed (X or Cancel), destroy it so rules reload from file
if( m_drcRuleEditorDlg && !m_drcRuleEditorDlg->IsShown() )
DestroyDRCRuleEditorDialog();
// Check if the rules file changed on disk since the dialog was last loaded
if( m_drcRuleEditorDlg )
{
wxFileName rulesFile( m_editFrame->GetDesignRulesPath() );
wxDateTime currentModTime;
if( rulesFile.FileExists() )
currentModTime = rulesFile.GetModificationTime();
if( !currentModTime.IsValid() || currentModTime != m_lastRulesFileModTime )
DestroyDRCRuleEditorDialog();
}
if( !m_drcRuleEditorDlg )
{
m_drcRuleEditorDlg = new DIALOG_DRC_RULE_EDITOR( m_editFrame, aParent );
updatePointers();
wxFileName rulesFile( m_editFrame->GetDesignRulesPath() );
if( rulesFile.FileExists() )
m_lastRulesFileModTime = rulesFile.GetModificationTime();
if( show_dlg_modal )
m_drcRuleEditorDlg->ShowModal();
else
@@ -113,7 +127,8 @@ void DRC_RULE_EDITOR_TOOL::ShowDRCRuleEditorDialog( wxWindow* aParent )
}
else
{
// Dialog is still visible but behind other windows, bring to front
// File unchanged, bring existing dialog to front
m_drcRuleEditorDlg->Show( true );
m_drcRuleEditorDlg->Raise();
}
}
+2 -1
View File
@@ -25,7 +25,7 @@
#include <memory>
#include <vector>
#include <tools/pcb_tool_base.h>
#include <wx/datetime.h>
class PCB_EDIT_FRAME;
class DIALOG_DRC_RULE_EDITOR;
@@ -80,6 +80,7 @@ private:
BOARD* m_pcb;
DIALOG_DRC_RULE_EDITOR* m_drcRuleEditorDlg;
std::shared_ptr<DRC_ENGINE> m_drcEngine;
wxDateTime m_lastRulesFileModTime;
};