From 35a3bac439609a950276f6dea6e0b8707bd800e3 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 28 Apr 2022 00:47:19 +0200 Subject: [PATCH] Use wxObjectDataPtr in wxSharedClientDataContainer This is slightly more economical, both at run-time and, maybe more importantly, at compile-time than using wxSharedPtr that we don't really need here, simple intrusive ref counting smart pointer is enough. --- include/wx/clntdata.h | 9 +++++++-- src/common/clntdata.cpp | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/wx/clntdata.h b/include/wx/clntdata.h index a340575191..d6df32e34b 100644 --- a/include/wx/clntdata.h +++ b/include/wx/clntdata.h @@ -14,7 +14,7 @@ #include "wx/defs.h" #include "wx/string.h" #include "wx/hashmap.h" -#include "wx/sharedptr.h" +#include "wx/object.h" typedef int (*wxShadowObjectMethod)(void*, void*); WX_DECLARE_STRING_HASH_MAP_WITH_DECL( @@ -187,13 +187,18 @@ protected: } private: + class wxRefCountedClientDataContainer : public wxClientDataContainer, + public wxRefCounter + { + }; + // Helper function that will create m_data if it is currently NULL wxClientDataContainer *GetValidClientData(); // m_data is shared, not deep copied, when cloned. If you make changes to // the data in one instance of your class, you change it for all cloned // instances! - wxSharedPtr m_data; + wxObjectDataPtr m_data; }; #endif // _WX_CLNTDATAH__ diff --git a/src/common/clntdata.cpp b/src/common/clntdata.cpp index 7e964b7de1..6ee5541545 100644 --- a/src/common/clntdata.cpp +++ b/src/common/clntdata.cpp @@ -96,7 +96,7 @@ wxClientDataContainer *wxSharedClientDataContainer::GetValidClientData() { if ( !HasClientDataContainer() ) { - m_data = new wxClientDataContainer; + m_data = new wxRefCountedClientDataContainer; } return m_data.get(); }