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
This commit is contained in:
jean-pierre charras
2024-10-21 17:33:14 +02:00
parent ccd4b0cf05
commit 48983dd31d
@@ -57,6 +57,7 @@
#include <locale_io.h>
#include <wx/app.h>
#include <wx/crt.h>
#include <wx/image.h>
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;