From 4447843dc1a021a70c96088b9fa0d0e434c8d786 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 14 Sep 2021 13:28:45 +0100 Subject: [PATCH] Defensive coding around getting an OnUpdateUI before we're ready. This appears to happen at least on GTK when the 3DFileResolver throws up error dialogs when paths can't be found. Fixes https://gitlab.com/kicad/code/kicad/issues/9163 --- pcbnew/dialogs/dialog_footprint_properties.cpp | 7 ++++++- pcbnew/dialogs/dialog_footprint_properties.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pcbnew/dialogs/dialog_footprint_properties.cpp b/pcbnew/dialogs/dialog_footprint_properties.cpp index e0554dd3bd..1dda401fb7 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.cpp +++ b/pcbnew/dialogs/dialog_footprint_properties.cpp @@ -67,7 +67,8 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen m_SolderPasteMarginUnits ), m_solderPasteRatio( aParent, m_PasteMarginRatioLabel, m_PasteMarginRatioCtrl, m_PasteMarginRatioUnits ), - m_returnValue( FP_PROPS_CANCEL ) + m_returnValue( FP_PROPS_CANCEL ), + m_initialized( false ) { // Create the 3D models page m_3dPanel = new PANEL_FP_PROPERTIES_3D_MODEL( m_frame, m_footprint, this, m_NoteBook ); @@ -150,6 +151,7 @@ DIALOG_FOOTPRINT_PROPERTIES::DIALOG_FOOTPRINT_PROPERTIES( PCB_EDIT_FRAME* aParen m_bpDelete->SetBitmap( KiBitmap( BITMAPS::small_trash ) ); finishDialogSettings(); + m_initialized = true; } @@ -617,6 +619,9 @@ void DIALOG_FOOTPRINT_PROPERTIES::adjustGridColumns( int aWidth ) void DIALOG_FOOTPRINT_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& ) { + if( !m_initialized ) + return; + if( !m_itemsGrid->IsCellEditControlShown() ) adjustGridColumns( m_itemsGrid->GetRect().GetWidth() ); diff --git a/pcbnew/dialogs/dialog_footprint_properties.h b/pcbnew/dialogs/dialog_footprint_properties.h index 25d1f12553..331bbc8e53 100644 --- a/pcbnew/dialogs/dialog_footprint_properties.h +++ b/pcbnew/dialogs/dialog_footprint_properties.h @@ -113,6 +113,8 @@ private: enum FP_PROPS_RETVALUE m_returnValue; // the option that closed the dialog PANEL_FP_PROPERTIES_3D_MODEL* m_3dPanel; + + bool m_initialized; };