From 48983dd31dd7ed4fe47cbe976845268ee6d46bed Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 21 Oct 2024 17:33:14 +0200 Subject: [PATCH] Python script: Ensure image handlers are loaded before loading a board,. because a board can include bitmap images using various formats, all available image handlers must be loaded. From master branch Fixes https://gitlab.com/kicad/code/kicad/-/issues/18959 --- pcbnew/python/scripting/pcbnew_scripting_helpers.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index 2f93274791..949aa94032 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -57,6 +57,7 @@ #include #include #include +#include static PCB_EDIT_FRAME* s_PcbEditFrame = nullptr; @@ -140,11 +141,13 @@ PROJECT* GetDefaultProject() return project; } + BOARD* LoadBoard( wxString& aFileName, PCB_IO_MGR::PCB_FILE_T aFormat ) { return LoadBoard( aFileName, aFormat, false ); } + BOARD* LoadBoard( wxString& aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, bool aSetActive ) { wxFileName pro = aFileName; @@ -152,6 +155,11 @@ BOARD* LoadBoard( wxString& aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, bool aSet pro.MakeAbsolute(); wxString projectPath = pro.GetFullPath(); + // Ensure image handlers are loaded, because a board can include bitmap images + // using various formats. + // By default only the BMP handler is available. + wxInitAllImageHandlers(); + // Ensure the "C" locale is temporary set, before reading any file // It also avoid wxWidget alerts about locale issues, later, when using Python 3 LOCALE_IO dummy;