Browse Source

DRC scripting: load project from board if possible

s_SettingsManager is not always initialized when the WriteDRCReport is
run.  We should first attempt to extract the project from the actual
board being checked.  Failing that, we fall back to the static settings manager and then exit if we don't have a project associated.

Fixes https://gitlab.com/kicad/code/kicad/issues/10221

(cherry picked from commit 78e737b9d8)
7.0
Seth Hillbrand 4 years ago
parent
commit
4f874057ab
  1. 11
      pcbnew/python/scripting/pcbnew_scripting_helpers.cpp

11
pcbnew/python/scripting/pcbnew_scripting_helpers.cpp

@ -457,7 +457,16 @@ bool WriteDRCReport( BOARD* aBoard, const wxString& aFileName, EDA_UNITS aUnits,
wxFileName fn = aBoard->GetFileName();
fn.SetExt( DesignRulesFileExtension );
wxString drcRulesPath = s_SettingsManager->Prj().AbsolutePath( fn.GetFullName() );
PROJECT* prj = nullptr;
if( aBoard->GetProject() )
prj = aBoard->GetProject();
else if( s_SettingsManager )
prj = &s_SettingsManager->Prj();
wxCHECK( prj, false );
wxString drcRulesPath = prj->AbsolutePath( fn.GetFullName() );
try
{

Loading…
Cancel
Save