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
This commit is contained in:
jean-pierre charras
2024-10-21 17:19:27 +02:00
parent f96c9b2f20
commit ab1b22d435
@@ -59,7 +59,7 @@
#include <locale_io.h>
#include <wx/app.h>
#include <wx/crt.h>
#include <wx/image.h>
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;