From 740dbdf09adaa3f5031fdf9fb8c0a37700e3cef1 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 21 Nov 2022 16:34:23 -0800 Subject: [PATCH] De-initialize propertygrid when done There doesn't appear to be a nice way to de-register wxPropertyGrids, so we need to reach into the singleton and remove our registered editor. Fixes https://gitlab.com/kicad/code/kicad/issues/12297 --- pcbnew/dialogs/pcb_properties_panel.cpp | 17 +++++++++++++++-- pcbnew/dialogs/pcb_properties_panel.h | 4 +--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/pcbnew/dialogs/pcb_properties_panel.cpp b/pcbnew/dialogs/pcb_properties_panel.cpp index 4e37cfc11d..ee71e272d9 100644 --- a/pcbnew/dialogs/pcb_properties_panel.cpp +++ b/pcbnew/dialogs/pcb_properties_panel.cpp @@ -38,8 +38,21 @@ PCB_PROPERTIES_PANEL::PCB_PROPERTIES_PANEL( wxWindow* aParent, PCB_EDIT_FRAME* a { m_propMgr.Rebuild(); - m_editor = wxPropertyGrid::RegisterEditorClass( new PG_UNIT_EDITOR( m_frame ), - wxT( "UnitEditor" ) ); + m_editor = wxPropertyGrid::RegisterEditorClass( new PG_UNIT_EDITOR( m_frame ) ); +} + + + +PCB_PROPERTIES_PANEL::~PCB_PROPERTIES_PANEL() +{ + auto it = wxPGGlobalVars->m_mapEditorClasses.find( m_editor->GetName() ); + + if( it != wxPGGlobalVars->m_mapEditorClasses.end() ) + { + wxPGGlobalVars->m_mapEditorClasses.erase( it ); + + delete static_cast( it->second ); + } } diff --git a/pcbnew/dialogs/pcb_properties_panel.h b/pcbnew/dialogs/pcb_properties_panel.h index 624e8e9afa..b44e9c8195 100644 --- a/pcbnew/dialogs/pcb_properties_panel.h +++ b/pcbnew/dialogs/pcb_properties_panel.h @@ -34,9 +34,7 @@ class PCB_PROPERTIES_PANEL : public PROPERTIES_PANEL public: PCB_PROPERTIES_PANEL( wxWindow* aParent, PCB_EDIT_FRAME* aFrame ); - virtual ~PCB_PROPERTIES_PANEL() - { - } + virtual ~PCB_PROPERTIES_PANEL(); void UpdateData() override;