Ugly hack to avoid crash on msys2 when running Pcbnew after running Eeschema+its Python console

The main bug still exists, but at least Kicad does not crash.
This commit is contained in:
jean-pierre charras 2021-08-14 21:08:56 +02:00
parent aae0e7e121
commit 8ac5e318fb
2 changed files with 23 additions and 9 deletions

View File

@ -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

View File

@ -32,6 +32,7 @@
#include "action_plugin.h"
#include "bitmaps.h"
#include "bitmap_store.h"
#include <pgm_base.h>
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 " );
}
}
}