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.
This commit is contained in:
Wayne Stambaugh 2021-01-13 09:20:05 -05:00
parent bedd785546
commit 6f0319e29f
2 changed files with 15 additions and 15 deletions

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt> * Copyright (C) 2016 Mario Luzeiro <mrluzeiro@ua.pt>
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com> * Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 ) if( m_modelViewer )
m_modelViewer->Set3DModel( m_FileTree->GetFilePath() ); m_modelViewer->Set3DModel( m_FileTree->GetFilePath() );
EndQuasiModal( wxID_OK ); EmulateButtonClickIfPresent( wxID_OK );
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com> * Copyright (C) 2016 Cirilo Bernardo <cirilo.bernardo@gmail.com>
* 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * 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 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: public:
DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager, FP_3DMODEL* aModelItem, DLG_SELECT_3DMODEL( wxWindow* aParent, S3D_CACHE* aCacheManager, FP_3DMODEL* aModelItem,
wxString& prevModelSelectDir, int& prevModelWildcard ); wxString& prevModelSelectDir, int& prevModelWildcard );
@ -61,6 +49,18 @@ public:
void OnFileActivated( wxCommandEvent& event )override; void OnFileActivated( wxCommandEvent& event )override;
void SetRootDir( wxCommandEvent& event ) override; void SetRootDir( wxCommandEvent& event ) override;
void Cfg3DPaths( 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 #endif // DLG_SELECT_3DMODEL_H