From f96c9b2f20f7bcd66b2e66192edfcf72ad91d365 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 21 Oct 2024 16:54:24 +0200 Subject: [PATCH] Avoid an wxASSERT when loading a board from a python script outside KiCad. In this case, a call to Pgm() generates a wxASSERT due to a nullptr. However this nullptr is not used, so using PgmOrNull() avoid this assert --- 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 e712e4d9fa..87916f9cf0 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2012 NBEE Embedded Systems, Miguel Angel Ajo - * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -203,7 +203,10 @@ BOARD* LoadBoard( const wxString& aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, boo // If empty, or not existing, the default drawing sheet is loaded. FILENAME_RESOLVER resolver; resolver.SetProject( project ); - resolver.SetProgramBase( &Pgm() ); + + // a PGM_BASE* process can be nullptr when running from a python script + // So use PgmOrNull() instead of &Pgm() to initialize the resolver + resolver.SetProgramBase( PgmOrNull() ); wxString filename = resolver.ResolvePath( BASE_SCREEN::m_DrawingSheetFileName, project->GetProjectPath(),