From 5e417302c5382406a518a2d58e4b5a81b3d3fe68 Mon Sep 17 00:00:00 2001 From: Artur Wieczorek Date: Sat, 21 May 2022 22:07:41 +0200 Subject: [PATCH] Don't store wxCursor object on the heap in wxPropertyGrid To simplify managing the life cycle of the object. --- include/wx/propgrid/propgrid.h | 2 +- src/propgrid/propgrid.cpp | 12 +++--------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/include/wx/propgrid/propgrid.h b/include/wx/propgrid/propgrid.h index 89b8b7eb92..4e5ffd2d6f 100644 --- a/include/wx/propgrid/propgrid.h +++ b/include/wx/propgrid/propgrid.h @@ -1463,7 +1463,7 @@ protected: wxBitmap *m_expandbmp, *m_collbmp; #endif - wxCursor *m_cursorSizeWE; + wxCursor m_cursorSizeWE; // wxWindow pointers to editor control(s). wxWindow *m_wndEditor; diff --git a/src/propgrid/propgrid.cpp b/src/propgrid/propgrid.cpp index 4366601d17..a8c3cad426 100644 --- a/src/propgrid/propgrid.cpp +++ b/src/propgrid/propgrid.cpp @@ -438,7 +438,7 @@ void wxPropertyGrid::Init2() #endif m_curcursor = wxCURSOR_ARROW; - m_cursorSizeWE = new wxCursor( wxCURSOR_SIZEWE ); + m_cursorSizeWE = wxCursor(wxCURSOR_SIZEWE); // adjust bitmap icon y position so they are centered m_vspacing = FromDIP(wxPG_DEFAULT_VSPACING); @@ -566,8 +566,6 @@ wxPropertyGrid::~wxPropertyGrid() if ( m_iFlags & wxPG_FL_CREATEDSTATE ) delete m_pState; - delete m_cursorSizeWE; - #ifndef wxPG_ICON_WIDTH delete m_expandbmp; delete m_collbmp; @@ -3852,12 +3850,8 @@ void wxPropertyGrid::CustomSetCursor( int type, bool override ) { if ( type == m_curcursor && !override ) return; - wxCursor* cursor = &wxPG_DEFAULT_CURSOR; - - if ( type == wxCURSOR_SIZEWE ) - cursor = m_cursorSizeWE; - - SetCursor( *cursor ); + wxCursor cursor = (type == wxCURSOR_SIZEWE) ? m_cursorSizeWE : wxPG_DEFAULT_CURSOR; + SetCursor(cursor); m_curcursor = type; }