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
This commit is contained in:
Jon Evans 2022-12-08 07:55:57 -05:00
parent 0a881e091c
commit 2b0d7f65d0
2 changed files with 24 additions and 10 deletions

View File

@ -31,6 +31,7 @@
#include <wx/settings.h> #include <wx/settings.h>
#include <wx/stattext.h> #include <wx/stattext.h>
#include <wx/propgrid/advprops.h>
extern APIIMPORT wxPGGlobalVarsClass* wxPGGlobalVars; extern APIIMPORT wxPGGlobalVarsClass* wxPGGlobalVars;
@ -48,6 +49,20 @@ PROPERTIES_PANEL::PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame )
if( !wxPGGlobalVars ) if( !wxPGGlobalVars )
wxPGInitResourceModule(); 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; delete wxPGGlobalVars->m_defaultRenderer;
wxPGGlobalVars->m_defaultRenderer = new PG_CELL_RENDERER(); wxPGGlobalVars->m_defaultRenderer = new PG_CELL_RENDERER();
@ -332,4 +347,4 @@ void PROPERTIES_PANEL::SetSplitterProportion( float aProportion )
{ {
m_splitter_key_proportion = aProportion; m_splitter_key_proportion = aProportion;
RecalculateSplitterPos(); RecalculateSplitterPos();
} }

View File

@ -44,16 +44,15 @@ PCB_PROPERTIES_PANEL::PCB_PROPERTIES_PANEL( wxWindow* aParent, PCB_EDIT_FRAME* a
m_propMgr.Rebuild(); m_propMgr.Rebuild();
bool found = false; bool found = false;
if( wxPGGlobalVars ) wxASSERT( wxPGGlobalVars );
{
auto it = wxPGGlobalVars->m_mapEditorClasses.find( PG_UNIT_EDITOR::EDITOR_NAME );
if( it != wxPGGlobalVars->m_mapEditorClasses.end() ) auto it = wxPGGlobalVars->m_mapEditorClasses.find( PG_UNIT_EDITOR::EDITOR_NAME );
{
m_editor = static_cast<PG_UNIT_EDITOR*>( it->second ); if( it != wxPGGlobalVars->m_mapEditorClasses.end() )
m_editor->UpdateFrame( m_frame ); {
found = true; m_editor = static_cast<PG_UNIT_EDITOR*>( it->second );
} m_editor->UpdateFrame( m_frame );
found = true;
} }
if( !found ) if( !found )