From 2b0d7f65d0b669a77d2ef6ad2d47471bf9021b0d Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 8 Dec 2022 07:55:57 -0500 Subject: [PATCH] Properties: sync wxPGGlobalVars map state with editor global state Thanks to @dsa-t for suggesting this (maybe) Fixes https://gitlab.com/kicad/code/kicad/-/issues/12297 --- common/widgets/properties_panel.cpp | 17 ++++++++++++++++- pcbnew/widgets/pcb_properties_panel.cpp | 17 ++++++++--------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/common/widgets/properties_panel.cpp b/common/widgets/properties_panel.cpp index 21a90204f5..e20b5f9c5c 100644 --- a/common/widgets/properties_panel.cpp +++ b/common/widgets/properties_panel.cpp @@ -31,6 +31,7 @@ #include #include +#include extern APIIMPORT wxPGGlobalVarsClass* wxPGGlobalVars; @@ -48,6 +49,20 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame ) if( !wxPGGlobalVars ) wxPGInitResourceModule(); + // See https://gitlab.com/kicad/code/kicad/-/issues/12297 + // and https://github.com/wxWidgets/wxWidgets/issues/11787 + if( wxPGGlobalVars->m_mapEditorClasses.empty() ) + { + wxPGEditor_TextCtrl = nullptr; + wxPGEditor_Choice = nullptr; + wxPGEditor_ComboBox = nullptr; + wxPGEditor_TextCtrlAndButton = nullptr; + wxPGEditor_CheckBox = nullptr; + wxPGEditor_ChoiceAndButton = nullptr; + wxPGEditor_SpinCtrl = nullptr; + wxPGEditor_DatePickerCtrl = nullptr; + } + delete wxPGGlobalVars->m_defaultRenderer; wxPGGlobalVars->m_defaultRenderer = new PG_CELL_RENDERER(); @@ -332,4 +347,4 @@ void PROPERTIES_PANEL::SetSplitterProportion( float aProportion ) { m_splitter_key_proportion = aProportion; RecalculateSplitterPos(); -} \ No newline at end of file +} diff --git a/pcbnew/widgets/pcb_properties_panel.cpp b/pcbnew/widgets/pcb_properties_panel.cpp index 091ee71d1a..e5874bc8c0 100644 --- a/pcbnew/widgets/pcb_properties_panel.cpp +++ b/pcbnew/widgets/pcb_properties_panel.cpp @@ -44,16 +44,15 @@ PCB_PROPERTIES_PANEL::PCB_PROPERTIES_PANEL( wxWindow* aParent, PCB_EDIT_FRAME* a m_propMgr.Rebuild(); bool found = false; - if( wxPGGlobalVars ) - { - auto it = wxPGGlobalVars->m_mapEditorClasses.find( PG_UNIT_EDITOR::EDITOR_NAME ); + wxASSERT( wxPGGlobalVars ); - if( it != wxPGGlobalVars->m_mapEditorClasses.end() ) - { - m_editor = static_cast( it->second ); - m_editor->UpdateFrame( m_frame ); - found = true; - } + auto it = wxPGGlobalVars->m_mapEditorClasses.find( PG_UNIT_EDITOR::EDITOR_NAME ); + + if( it != wxPGGlobalVars->m_mapEditorClasses.end() ) + { + m_editor = static_cast( it->second ); + m_editor->UpdateFrame( m_frame ); + found = true; } if( !found )