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
This commit is contained in:
Seth Hillbrand 2022-01-06 11:45:37 -08:00
parent d014f0307b
commit 78e737b9d8
1 changed files with 10 additions and 1 deletions

View File

@ -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
{