From ab1b22d435b17ea372dd129287a20865f4b4da12 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 21 Oct 2024 17:19:27 +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. Fixes https://gitlab.com/kicad/code/kicad/-/issues/18959 --- pcbnew/python/scripting/pcbnew_scripting_helpers.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp index 87916f9cf0..d795b0a3e7 100644 --- a/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp +++ b/pcbnew/python/scripting/pcbnew_scripting_helpers.cpp @@ -59,7 +59,7 @@ #include #include #include - +#include static PCB_EDIT_FRAME* s_PcbEditFrame = nullptr; static SETTINGS_MANAGER* s_SettingsManager = nullptr; @@ -147,6 +147,7 @@ BOARD* LoadBoard( const wxString& aFileName, PCB_IO_MGR::PCB_FILE_T aFormat ) return LoadBoard( aFileName, aFormat, false ); } + BOARD* LoadBoard( const wxString& aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, bool aSetActive, PROJECT* aProject ) { @@ -155,6 +156,12 @@ BOARD* LoadBoard( const wxString& aFileName, PCB_IO_MGR::PCB_FILE_T aFormat, boo 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;