IPC_API: fix crash in PLUGIN_AVAILABILITY_CHANGED event handler (schematic)

Re-opening SCH while the PCB is open leads to crash.

Same as 441b2686d3150b1c3e0629c3d49857f1c47e3871, but for schematic editor.
This commit is contained in:
Alex Shvartzkop 2024-07-05 02:15:20 +03:00
parent b2aee0bf74
commit cabf7d4878
2 changed files with 20 additions and 6 deletions

View File

@ -189,12 +189,7 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
#ifdef KICAD_IPC_API
wxTheApp->Bind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED,
[&]( wxCommandEvent& aEvt )
{
wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
ReCreateHToolbar();
aEvt.Skip();
} );
&SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
#endif
m_hierarchy = new HIERARCHY_PANE( this );
@ -429,6 +424,12 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
SCH_EDIT_FRAME::~SCH_EDIT_FRAME()
{
#ifdef KICAD_IPC_API
Pgm().GetApiServer().DeregisterHandler( m_apiHandler.get() );
wxTheApp->Unbind( EDA_EVT_PLUGIN_AVAILABILITY_CHANGED,
&SCH_EDIT_FRAME::onPluginAvailabilityChanged, this );
#endif
m_hierarchy->Unbind( wxEVT_SIZE, &SCH_EDIT_FRAME::OnResizeHierarchyNavigator, this );
// Ensure m_canvasType is up to date, to save it in config
@ -2553,3 +2554,12 @@ void SCH_EDIT_FRAME::updateSelectionFilterVisbility()
selectionFilterPane.Show( showFilter );
}
#ifdef KICAD_IPC_API
void SCH_EDIT_FRAME::onPluginAvailabilityChanged( wxCommandEvent& aEvt )
{
wxLogTrace( traceApi, "SCH frame: EDA_EVT_PLUGIN_AVAILABILITY_CHANGED" );
ReCreateHToolbar();
aEvt.Skip();
}
#endif

View File

@ -923,6 +923,10 @@ protected:
void updateSelectionFilterVisbility() override;
#ifdef KICAD_IPC_API
void onPluginAvailabilityChanged( wxCommandEvent& aEvt );
#endif
private:
// Called when resizing the Hierarchy Navigator panel
void OnResizeHierarchyNavigator( wxSizeEvent& aEvent );