DRC Rule Editor: Only reload when rules file changes on disk
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user