From 78e737b9d87822d81f9a99565fc1db456923234e Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 6 Jan 2022 11:45:37 -0800 Subject: [PATCH] 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 --- pcbnew/python/scripting/pcbnew_scripting_helpers.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index f18cc58cda..59d0be12a3 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/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 {