From 6f0319e29fa51cb09a7d0354e9cef812b9e96cf8 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Wed, 13 Jan 2021 09:20:05 -0500 Subject: [PATCH] Fix potential bug in 3D model selection dialog. Calling EndModal or EndQuasiModal will cause KiCad to hang if the dialog was not opened in the same manor. The modality of the dialog must be checked and the appropriate end method must be called or emulate a button click which allows the default dialog close method to be called to handle shutting down the dialog correctly. --- .../3d_cache/dialogs/dlg_select_3dmodel.cpp | 4 +-- .../3d_cache/dialogs/dlg_select_3dmodel.h | 26 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp index b7d4492417..8fec3bf6e7 100644 --- a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp +++ b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2016 Mario Luzeiro * Copyright (C) 2016 Cirilo Bernardo - * Copyright (C) 2017-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2021 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 @@ -184,7 +184,7 @@ void DLG_SELECT_3DMODEL::OnFileActivated( wxCommandEvent& event ) if( m_modelViewer ) m_modelViewer->Set3DModel( m_FileTree->GetFilePath() ); - EndQuasiModal( wxID_OK ); + EmulateButtonClickIfPresent( wxID_OK ); } diff --git a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.h b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.h index 0bc11b6fa3..ddcba4dfe2 100644 --- a/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.h +++ b/3d-viewer/3d_cache/dialogs/dlg_select_3dmodel.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Cirilo Bernardo - * Copyright (C) 2018 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2018-2021 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 @@ -40,18 +40,6 @@ class C3D_MODEL_VIEWER; class DLG_SELECT_3DMODEL : public DLG_SELECT_3D_MODELE_BASE { -private: - FP_3DMODEL* m_model; // data for the selected model - S3D_CACHE* m_cache; // cache manager - FILENAME_RESOLVER* m_resolver; // 3D filename resolver - - wxString& m_previousDir; - int& m_previousFilterIndex; - - C3D_MODEL_VIEWER* m_modelViewer; - - void updateDirChoiceList( void ); - public: DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager, FP_3DMODEL* aModelItem, wxString& prevModelSelectDir, int& prevModelWildcard ); @@ -61,6 +49,18 @@ public: void OnFileActivated( wxCommandEvent& event )override; void SetRootDir( wxCommandEvent& event ) override; void Cfg3DPaths( wxCommandEvent& event ) override; + +private: + void updateDirChoiceList( void ); + + FP_3DMODEL* m_model; // data for the selected model + S3D_CACHE* m_cache; // cache manager + FILENAME_RESOLVER* m_resolver; // 3D filename resolver + + wxString& m_previousDir; + int& m_previousFilterIndex; + + C3D_MODEL_VIEWER* m_modelViewer; }; #endif // DLG_SELECT_3DMODEL_H