From 9440b473c0e5f68c4f2ee4360690cdaa4e0709b7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Dec 2022 20:34:47 +0000 Subject: [PATCH] Deprecate unused wxTextDataObject::GetTextLength() This function was supposed to be overridden in the subclasses to allow efficiently implementing GetDataSize(), but it wasn't actually called any longer since 229f00eb69 (Translate wxTextDataObject to/from native EOL format., 2012-07-29). And while it was probably a mistake to stop calling it in that commit, the fact that nobody has complained about it since then seems to prove that nobody was overriding it anyhow and it's not worth resurrecting it, so just deprecate it instead. --- include/wx/dataobj.h | 4 +++- interface/wx/dataobj.h | 13 ++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/wx/dataobj.h b/include/wx/dataobj.h index 5bed7a5b9d..73e1fa09d3 100644 --- a/include/wx/dataobj.h +++ b/include/wx/dataobj.h @@ -373,7 +373,6 @@ public: // virtual functions which you may override if you want to provide text on // demand only - otherwise, the trivial default versions will be used - virtual size_t GetTextLength() const { return m_text.Len() + 1; } virtual wxString GetText() const { return m_text; } virtual void SetText(const wxString& text) { m_text = text; } @@ -412,6 +411,9 @@ public: } #endif // different wxTextDataObject implementations + wxDEPRECATED_MSG("Don't call nor override this function") + size_t GetTextLength() const { return m_text.Len() + 1; } + private: #if defined(__WXQT__) // Overridden to set text directly instead of extracting byte array diff --git a/interface/wx/dataobj.h b/interface/wx/dataobj.h index 57a181d057..0fda3c1124 100644 --- a/interface/wx/dataobj.h +++ b/interface/wx/dataobj.h @@ -711,8 +711,7 @@ public: providing text on-demand in order to minimize memory consumption when offering data in several formats, such as plain text and RTF because by default the text is stored in a string in this class, but it might as well - be generated when requested. For this, GetTextLength() and GetText() will - have to be overridden. + be generated when requested, in which case GetText() should be overridden. Note that if you already have the text inside a string, you will not achieve any efficiency gain by overriding these functions because copying @@ -743,12 +742,12 @@ public: virtual wxString GetText() const; /** - Returns the data size. By default, returns the size of the text data - set in the constructor or using SetText(). This can be overridden to - provide text size data on-demand. It is recommended to return the text - length plus 1 for a trailing zero, but this is not strictly required. + @deprecated + + Don't use or call this function, it simply returns the length of the + text plus one for compatibility purposes. */ - virtual size_t GetTextLength() const; + size_t GetTextLength() const; /** Returns 2 under wxMac and wxGTK, where text data coming from the