From 620e02c568bb7cc410b10ede1b592c20c02dfb9f Mon Sep 17 00:00:00 2001 From: Artur Wieczorek <7330332+a-wi@users.noreply.github.com> Date: Wed, 8 Feb 2023 18:01:31 +0100 Subject: [PATCH] Fix life cycle of dynamically allocated wxPGProperty label Label should be allocated in wxPGGlobalVarsClass ctor and disposed in dtor. Closes #23237. --- src/propgrid/property.cpp | 2 +- src/propgrid/propgrid.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/propgrid/property.cpp b/src/propgrid/property.cpp index e4288375fa..db1ef35c27 100644 --- a/src/propgrid/property.cpp +++ b/src/propgrid/property.cpp @@ -529,7 +529,7 @@ wxPGChoiceEntry& wxPGChoicesData::Insert(int index, wxIMPLEMENT_ABSTRACT_CLASS(wxPGProperty, wxObject); #if WXWIN_COMPATIBILITY_3_2 -wxString* wxPGProperty::sm_wxPG_LABEL = new wxString("@!"); +wxString* wxPGProperty::sm_wxPG_LABEL = nullptr; #endif // WXWIN_COMPATIBILITY_3_2 const wxString wxPGProperty::sm_labelItem("@!"); diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index ecdbe8fe64..77a3156d85 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -204,6 +204,10 @@ wxPGGlobalVarsClass::wxPGGlobalVarsClass() , m_extraStyle(0) , m_warnings(0) { +#if WXWIN_COMPATIBILITY_3_2 + wxPGProperty::sm_wxPG_LABEL = new wxString("@!"); +#endif // WXWIN_COMPATIBILITY_3_2 + /* TRANSLATORS: Name of Boolean false value */ m_boolChoices.Add(_("False")); /* TRANSLATORS: Name of Boolean true value */