From 69453964b49d428cb8a111b0890980ccbcc5539f Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 5 Mar 2022 18:26:33 +0100 Subject: [PATCH] pcbnew_scripting_helpers: fix a potential crash when running a script outside kicad. BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat ) crashes if a old project file (*.pro) exists and the *.kicad_pro file doses not exists. The crash happens when trying to convert the old config outside kicad. --- pcbnew/python/scripting/pcbnew_scripting_helpers.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index 08069fedb0..e88d9693a7 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -141,8 +141,11 @@ BOARD* LoadBoard( wxString& aFileName, IO_MGR::PCB_FILE_T aFormat ) if( !project ) { - GetSettingsManager()->LoadProject( projectPath, false ); - project = GetSettingsManager()->GetProject( projectPath ); + if( wxFileExists( projectPath ) ) + { + GetSettingsManager()->LoadProject( projectPath, false ); + project = GetSettingsManager()->GetProject( projectPath ); + } } else if( s_PcbEditFrame && project == &GetSettingsManager()->Prj() ) {