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.
This commit is contained in:
Vadim Zeitlin 2022-12-04 20:34:47 +00:00
parent 0f54ec8b36
commit 9440b473c0
2 changed files with 9 additions and 8 deletions

View file

@ -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

View file

@ -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