diff --git a/bitmap2component/bitmap2cmp_main.cpp b/bitmap2component/bitmap2cmp_main.cpp index 49f2b97a24..92dd22addd 100644 --- a/bitmap2component/bitmap2cmp_main.cpp +++ b/bitmap2component/bitmap2cmp_main.cpp @@ -93,6 +93,13 @@ PGM_BASE& Pgm() wxASSERT( process ); // KIFACE_GETTER has already been called. return *process; } + + +// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from a python script. +PGM_BASE* PgmOrNull() +{ + return process; +} #endif diff --git a/pcbnew/action_plugin.cpp b/pcbnew/action_plugin.cpp index 24f299dc5d..2a1d90bd22 100644 --- a/pcbnew/action_plugin.cpp +++ b/pcbnew/action_plugin.cpp @@ -32,6 +32,7 @@ #include "action_plugin.h" #include "bitmaps.h" #include "bitmap_store.h" +#include ACTION_PLUGIN::~ACTION_PLUGIN() @@ -159,19 +160,25 @@ void ACTION_PLUGINS::register_action( ACTION_PLUGIN* aAction ) } } - // Load icon if supplied - wxString icon_file_name = aAction->GetIconFileName( GetBitmapStore()->IsDarkTheme() ); + wxASSERT( PgmOrNull() ); // PgmOrNull() returning nullptr should never happen, + // but it sometimes happens on msys2 build - if( !icon_file_name.IsEmpty() ) + if( PgmOrNull() ) // Hack for msys2. Must be removed when the root cause is fixed { - { - wxLogNull eat_errors; - aAction->iconBitmap.LoadFile( icon_file_name, wxBITMAP_TYPE_PNG ); - } + // Load icon if supplied + wxString icon_file_name = aAction->GetIconFileName( GetBitmapStore()->IsDarkTheme() ); - if ( !aAction->iconBitmap.IsOk() ) + if( !icon_file_name.IsEmpty() ) { - wxLogVerbose( "Failed to load icon " + icon_file_name + " for action plugin " ); + { + wxLogNull eat_errors; + aAction->iconBitmap.LoadFile( icon_file_name, wxBITMAP_TYPE_PNG ); + } + + if ( !aAction->iconBitmap.IsOk() ) + { + wxLogVerbose( "Failed to load icon " + icon_file_name + " for action plugin " ); + } } }