Footprint editor: ensure the pad editor is closed before load a new footprint.

When editing a new footprint from the board editor, if the Footprint editor has the pad editor
open, there is a risk of crash when replacing the footprint in edit.

Fixes #6892
https://gitlab.com/kicad/code/kicad/issues/6892
This commit is contained in:
jean-pierre charras 2020-12-31 10:53:14 +01:00
parent 82e728dbf6
commit a6a2dae480
3 changed files with 12 additions and 0 deletions

View File

@ -135,6 +135,8 @@ DIALOG_PAD_PROPERTIES::DIALOG_PAD_PROPERTIES( PCB_BASE_FRAME* aParent, PAD* aPad
m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true ), m_spokeWidth( aParent, m_spokeWidthLabel, m_spokeWidthCtrl, m_spokeWidthUnits, true ),
m_thermalGap( aParent, m_thermalGapLabel, m_thermalGapCtrl, m_thermalGapUnits, true ) m_thermalGap( aParent, m_thermalGapLabel, m_thermalGapCtrl, m_thermalGapUnits, true )
{ {
SetName( PAD_PROPERTIES_DLG_NAME );
m_currentPad = aPad; // aPad can be NULL, if the dialog is called m_currentPad = aPad; // aPad can be NULL, if the dialog is called
// from the footprint editor to set default pad setup // from the footprint editor to set default pad setup

View File

@ -44,6 +44,9 @@
* DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE, * DIALOG_PAD_PROPERTIES, derived from DIALOG_PAD_PROPERTIES_BASE,
* created by wxFormBuilder * created by wxFormBuilder
*/ */
// The wxWidgets window name. Used to retrieve the dialog by window name
#define PAD_PROPERTIES_DLG_NAME "pad_properties_dlg_name"
class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE class DIALOG_PAD_PROPERTIES : public DIALOG_PAD_PROPERTIES_BASE
{ {
public: public:

View File

@ -51,6 +51,7 @@ using namespace std::placeholders;
#include <view/view_controls.h> #include <view/view_controls.h>
#include <widgets/lib_tree.h> #include <widgets/lib_tree.h>
#include <widgets/progress_reporter.h> #include <widgets/progress_reporter.h>
#include <dialog_pad_properties.h>
#include "fp_tree_model_adapter.h" #include "fp_tree_model_adapter.h"
@ -98,6 +99,12 @@ bool FOOTPRINT_EDIT_FRAME::LoadFootprintFromBoard( FOOTPRINT* aFootprint )
if( aFootprint == NULL ) if( aFootprint == NULL )
return false; return false;
// Ensure we do not have the pad editor open (that is apseudo modal dlg).
// LoadFootprintFromBoard() can be called from the board editor, and we must ensure
// no footprint item is currently in edit
if( wxWindow::FindWindowByName( PAD_PROPERTIES_DLG_NAME ) )
wxWindow::FindWindowByName( PAD_PROPERTIES_DLG_NAME )->Close();
if( !Clear_Pcb( true ) ) if( !Clear_Pcb( true ) )
return false; return false;