From 47e7cd2e9029590cbce552043d5c526ef23a4709 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sun, 4 Dec 2022 10:25:57 -0800 Subject: [PATCH] Don't allocate/delete a PG_UNIT_EDITOR unless needed We cannot actually delete the PG_UNIT_EDITOR without substantial issues from the global variables in wx. --- pcbnew/widgets/pcb_properties_panel.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pcbnew/widgets/pcb_properties_panel.cpp b/pcbnew/widgets/pcb_properties_panel.cpp index 9457bae4af..d25d1ac3c5 100644 --- a/pcbnew/widgets/pcb_properties_panel.cpp +++ b/pcbnew/widgets/pcb_properties_panel.cpp @@ -42,11 +42,9 @@ PCB_PROPERTIES_PANEL::PCB_PROPERTIES_PANEL( wxWindow* aParent, PCB_EDIT_FRAME* a m_propMgr.Rebuild(); bool found = false; - PG_UNIT_EDITOR* new_editor = new PG_UNIT_EDITOR( m_frame ); - if( wxPGGlobalVars ) { - auto it = wxPGGlobalVars->m_mapEditorClasses.find( new_editor->GetName() ); + auto it = wxPGGlobalVars->m_mapEditorClasses.find( PG_UNIT_EDITOR::EDITOR_NAME ); if( it != wxPGGlobalVars->m_mapEditorClasses.end() ) { @@ -56,10 +54,11 @@ PCB_PROPERTIES_PANEL::PCB_PROPERTIES_PANEL( wxWindow* aParent, PCB_EDIT_FRAME* a } } - if( found ) - delete new_editor; - else + if( !found ) + { + PG_UNIT_EDITOR* new_editor = new PG_UNIT_EDITOR( m_frame ); m_editor = static_cast( wxPropertyGrid::RegisterEditorClass( new_editor ) ); + } }