7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 00:21:25 +00:00

Fix thread deadlock when closing the footprint chooser dialog.

Fixing this required disabling the footprint/3D viewer canvas drawing
before destroying the canvas in the dialog dtor.  This in turn required
adding a virtual method to DIALOG_SHIM that can be overridden by the
derived object to allow performing actions during dialog shutdown that
can be problematic when performed in the dialog dtor.  Please note that
this only works for quasi-modal dialogs.  Modal and modeless dialogs
should use close window events.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18107
This commit is contained in:
Wayne Stambaugh 2024-12-18 08:13:15 -05:00
parent 1b05e77fb2
commit 2e7d819b5d
5 changed files with 43 additions and 5 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2023 CERN
* Copyright (C) 2012-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2012-2023, 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -575,6 +575,8 @@ void DIALOG_SHIM::EndQuasiModal( int retCode )
return;
}
TearDownQuasiModal();
if( m_qmodal_loop )
{
if( m_qmodal_loop->IsRunning() )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 2012-2019 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2012-2019, 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -191,6 +191,15 @@ protected:
virtual void OnCharHook( wxKeyEvent& aEvt );
/**
* Override this method to perform dialog tear down actions not suitable for object dtor.
*
* @warning This only gets called for dialogs that are shown in the quasimodal mode. If
* you need to perform tear down actions in modal or modeless dialogs, create
* a close window event handler.
*/
virtual void TearDownQuasiModal() {}
private:
/**
* Properly handle the wxCloseEvent when in the quasimodal mode when not calling

View File

@ -279,3 +279,28 @@ void DIALOG_FOOTPRINT_CHOOSER::onFpViewReq( wxCommandEvent& event )
m_chooserPanel->m_RightPanel->Layout();
m_chooserPanel->m_RightPanel->Refresh();
}
void DIALOG_FOOTPRINT_CHOOSER::TearDownQuasiModal()
{
wxLogDebug( wxS( "Entering DIALOG_FOOTPRINT_CHOOSER::TearDownQuasiModal()" ) );
if( m_chooserPanel )
{
FOOTPRINT_PREVIEW_WIDGET* viewerWidget = m_chooserPanel->GetViewerPanel();
if( viewerWidget )
{
FOOTPRINT_PREVIEW_PANEL_BASE* previewPanel = viewerWidget->GetPreviewPanel();
FOOTPRINT_PREVIEW_PANEL* fpPreviewPanel =
static_cast<FOOTPRINT_PREVIEW_PANEL*>( previewPanel );
if( fpPreviewPanel )
{
wxLogDebug( wxS( "Stopping footprint preview panel drawing." ) );
fpPreviewPanel->StopDrawing();
}
}
}
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2023, 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -61,6 +61,8 @@ protected:
void build3DCanvas();
virtual void TearDownQuasiModal() override;
protected:
PANEL_FOOTPRINT_CHOOSER* m_chooserPanel;
bool m_showFpMode; // True to show the footprint, false for the 3D model

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2018 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2020, 2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -190,7 +190,7 @@ FOOTPRINT* PCB_BASE_FRAME::SelectFootprintFromLibrary( LIB_ID aPreselect )
DIALOG_FOOTPRINT_CHOOSER dialog( this, aPreselect, s_FootprintHistoryList );
if( dialog.ShowModal() == wxID_CANCEL )
if( dialog.ShowQuasiModal() == wxID_CANCEL )
return nullptr;
fpid = dialog.GetSelectedLibId();