Attempt to fix destruction order crash (KICAD-6KC).

This commit is contained in:
Jeff Young 2025-06-23 21:38:56 -06:00
parent 0d013498ef
commit a7fdea9b6f
4 changed files with 22 additions and 14 deletions

View File

@ -281,7 +281,20 @@ LIB_TREE::~LIB_TREE()
m_details_ctrl->Unbind( wxEVT_HTML_LINK_CLICKED, &LIB_TREE::onDetailsLink, this );
m_hoverTimer.Stop();
destroyPreview();
}
void LIB_TREE::ShutdownPreviews()
{
m_hoverTimer.Stop();
m_previewDisabled = true;
if( m_previewWindow )
{
m_previewWindow->Hide();
m_previewWindow->Destroy();
m_previewWindow = nullptr;
}
}
@ -754,18 +767,6 @@ void LIB_TREE::hidePreview()
}
void LIB_TREE::destroyPreview()
{
hidePreview();
if( m_previewWindow )
{
m_previewWindow->Destroy();
m_previewWindow = nullptr;
}
}
void LIB_TREE::onIdle( wxIdleEvent& aEvent )
{
// The wxDataViewCtrl won't give us its mouseMoved events so we're forced to use idle

View File

@ -687,6 +687,9 @@ bool SYMBOL_EDIT_FRAME::canCloseWindow( wxCloseEvent& aEvent )
void SYMBOL_EDIT_FRAME::doCloseWindow()
{
if( GetLibTree() )
GetLibTree()->ShutdownPreviews();
Destroy();
}

View File

@ -180,6 +180,8 @@ public:
m_previewDisabled = aBlock;
}
void ShutdownPreviews();
protected:
/**
* Expand or collapse a node, switching it to the opposite state.
@ -232,7 +234,6 @@ protected:
void showPreview( wxDataViewItem aItem );
void hidePreview();
void destroyPreview();
void onQueryText( wxCommandEvent& aEvent );
void onQueryCharHook( wxKeyEvent& aEvent );

View File

@ -930,6 +930,9 @@ void FOOTPRINT_EDIT_FRAME::doCloseWindow()
GetCanvas()->SetEventDispatcher( nullptr );
GetCanvas()->StopDrawing();
if( GetLibTree() )
GetLibTree()->ShutdownPreviews();
// Do not show the layer manager during closing to avoid flicker
// on some platforms (Windows) that generate useless redraw of items in
// the Layer Manager