From 6dd129049fd13d793afd91399b2ccfbe38ddd9c5 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek <7330332+a-wi@users.noreply.github.com> Date: Fri, 22 Dec 2023 22:46:54 +0100 Subject: [PATCH] Initialize array for wxPropertyGrid alphabetic mode only once Array holding items to use in non-categoric mode should be created and initially populated only once. Closes #24145. --- include/wx/propgrid/propgridpagestate.h | 1 - src/propgrid/propgridpagestate.cpp | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/wx/propgrid/propgridpagestate.h b/include/wx/propgrid/propgridpagestate.h index 67f93869a1..60904042dd 100644 --- a/include/wx/propgrid/propgridpagestate.h +++ b/include/wx/propgrid/propgridpagestate.h @@ -813,7 +813,6 @@ protected: bool m_dontCenterSplitter; private: - // Only inits arrays, doesn't migrate things or such. void InitNonCatMode(); }; diff --git a/src/propgrid/propgridpagestate.cpp b/src/propgrid/propgridpagestate.cpp index e5e29f793f..e69b0d4a52 100644 --- a/src/propgrid/propgridpagestate.cpp +++ b/src/propgrid/propgridpagestate.cpp @@ -219,12 +219,14 @@ wxPropertyGridPageState::~wxPropertyGridPageState() void wxPropertyGridPageState::InitNonCatMode() { - if ( !m_abcArray ) - { - m_abcArray = new wxPGRootProperty(wxS("")); - m_abcArray->SetParentState(this); - m_abcArray->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES); - } + // Initialize and populate array holding properties in alphabetic (non-categoric) + // mode only once. + if (m_abcArray) + return; + + m_abcArray = new wxPGRootProperty(wxS("")); + m_abcArray->SetParentState(this); + m_abcArray->SetFlag(wxPG_PROP_CHILDREN_ARE_COPIES); // Must be called when state::m_properties still points to regularArray. wxPGProperty* oldProperties = m_properties;