Moving checking the rules up a level so we can properly exit DRC dialog.

Fixes https://gitlab.com/kicad/code/kicad/issues/5778
This commit is contained in:
Jeff Young 2020-09-24 15:17:18 +01:00
parent 3e366a901f
commit 5ad76a237e
3 changed files with 26 additions and 25 deletions

View File

@ -40,6 +40,7 @@
#include <widgets/ui_common.h>
#include <widgets/progress_reporter.h>
#include <drc/drc_engine.h>
#include <dialogs/panel_setup_rules_base.h>
#include <tools/drc_tool.h>
#include <kiplatform/ui.h>
@ -199,11 +200,29 @@ void DIALOG_DRC::syncCheckboxes()
void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
{
DRC_TOOL* drcTool = m_parentFrame->GetToolManager()->GetTool<DRC_TOOL>();
bool testTracksAgainstZones = m_cbReportTracksToZonesErrors->GetValue();
bool refillZones = m_cbRefillZones->GetValue();
bool reportAllTrackErrors = m_cbReportAllTrackErrors->GetValue();
bool testFootprints = m_cbTestFootprints->GetValue();
DRC_TOOL* drcTool = m_brdEditor->GetToolManager()->GetTool<DRC_TOOL>();
bool testTracksAgainstZones = m_cbReportTracksToZonesErrors->GetValue();
bool refillZones = m_cbRefillZones->GetValue();
bool reportAllTrackErrors = m_cbReportAllTrackErrors->GetValue();
bool testFootprints = m_cbTestFootprints->GetValue();
// This is not the time to have stale or buggy rules. Ensure they're up-to-date
// and that they at least parse.
try
{
drcTool->GetDRCEngine()->InitEngine( m_parentFrame->Prj().AbsolutePath( "drc-rules" ) );
}
catch( PARSE_ERROR& pe )
{
// Shouldn't be necessary, but we get into all kinds of wxWidgets window ordering
// issues (on at least OSX) if we don't.
drcTool->DestroyDRCDialog();
m_brdEditor->ShowBoardSetupDialog( _( "Rules" ), pe.What(), ID_RULES_EDITOR,
pe.lineNumber, pe.byteIndex );
return;
}
m_drcRun = false;
m_footprintTestsRun = false;

View File

@ -33,10 +33,8 @@
#include <dialog_drc.h>
#include <board_commit.h>
#include <widgets/progress_reporter.h>
#include <drc/drc_engine.h>
#include <drc/drc_results_provider.h>
#include <netlist_reader/pcb_netlist.h>
#include <dialogs/panel_setup_rules_base.h>
DRC_TOOL::DRC_TOOL() :
PCB_TOOL_BASE( "pcbnew.DRCTool" ),
@ -143,24 +141,6 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aTestTracksA
NETLIST netlist;
wxWindowDisabler disabler( /* disable everything except: */ m_drcDialog );
// This is not the time to have stale or buggy rules. Ensure they're up-to-date
// and that they at least parse.
try
{
m_drcEngine->InitEngine( m_editFrame->Prj().AbsolutePath( "drc-rules" ) );
}
catch( PARSE_ERROR& pe )
{
// Shouldn't be necessary, but we get into all kinds of wxWidgets window ordering
// issues (on at least OSX) if we don't.
DestroyDRCDialog();
m_editFrame->ShowBoardSetupDialog( _( "Rules" ), pe.What(), ID_RULES_EDITOR,
pe.lineNumber, pe.byteIndex );
return;
}
m_drcRunning = true;
if( aRefillZones )

View File

@ -110,6 +110,8 @@ public:
*/
void DestroyDRCDialog();
std::shared_ptr<DRC_ENGINE> GetDRCEngine() { return m_drcEngine; }
/**
* Run the DRC tests.
*/