From 81ac38cf652f997b297d80c82a95642e2da84501 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 29 Apr 2023 23:18:24 +0100 Subject: [PATCH] Remove manual memory management code for tooltips in wxStatusBar Use a vector of unique_ptr<> to manage memory automatically instead. No real changes, this just simplifies the code and makes it more robust by making it impossible to forget to delete a tooltip. --- include/wx/msw/statusbar.h | 14 ++++++++------ src/msw/statusbar.cpp | 19 ++++--------------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/include/wx/msw/statusbar.h b/include/wx/msw/statusbar.h index a54d3cd89e..67a008ce0b 100644 --- a/include/wx/msw/statusbar.h +++ b/include/wx/msw/statusbar.h @@ -13,9 +13,11 @@ #if wxUSE_NATIVE_STATUSBAR -#include "wx/vector.h" #include "wx/tooltip.h" +#include +#include + class WXDLLIMPEXP_FWD_CORE wxClientDC; class WXDLLIMPEXP_CORE wxStatusBar : public wxStatusBarBase @@ -79,11 +81,6 @@ protected: // used by DoUpdateStatusText() wxClientDC *m_pDC; -#if wxUSE_TOOLTIPS - // the tooltips used when wxSTB_SHOW_TIPS is given - wxVector m_tooltips; -#endif - private: struct MSWBorders { @@ -107,6 +104,11 @@ private: // return the various status bar metrics static const MSWMetrics& MSWGetMetrics(); +#if wxUSE_TOOLTIPS + // the tooltips used when wxSTB_SHOW_TIPS is given + std::vector> m_tooltips; +#endif + wxDECLARE_DYNAMIC_CLASS_NO_COPY(wxStatusBar); }; diff --git a/src/msw/statusbar.cpp b/src/msw/statusbar.cpp index e9a2c86a06..30302187f1 100644 --- a/src/msw/statusbar.cpp +++ b/src/msw/statusbar.cpp @@ -147,14 +147,6 @@ wxStatusBar::~wxStatusBar() // occupy PostSizeEventToParent(); -#if wxUSE_TOOLTIPS - // delete existing tooltips - for (size_t i=0; i