X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4ec4d8610acc3b62bdc59e5732bce57b63290e70..2036bdd30368d117918b565ae990a89841281f33:/include/wx/buffer.h diff --git a/include/wx/buffer.h b/include/wx/buffer.h index c4cb0dc208..d06fbf6fc1 100644 --- a/include/wx/buffer.h +++ b/include/wx/buffer.h @@ -105,9 +105,12 @@ public: wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src) { - if ( m_owned ) - free(m_str); - CopyFrom(src); + if (&src != this) + { + if ( m_owned ) + free(m_str); + CopyFrom(src); + } return *this; } @@ -150,6 +153,8 @@ private: bool m_owned; }; +WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer ) + class WXDLLIMPEXP_BASE wxCharBuffer : public wxCharTypeBuffer { public: @@ -165,6 +170,8 @@ public: }; #if wxUSE_WCHAR_T +WXDLLIMPEXP_TEMPLATE_INSTANCE_BASE( wxCharTypeBuffer ) + class WXDLLIMPEXP_BASE wxWCharBuffer : public wxCharTypeBuffer { public: @@ -222,6 +229,13 @@ typedef wxWritableCharTypeBuffer wxWritableWCharBuffer; #define wxWX2WCbuf wxWCharBuffer #endif // Unicode/ANSI +// type of the value returned by wxString::utf8_str() +#if wxUSE_UNICODE_UTF8 + #define wxUTF8Buf char * +#else + #define wxUTF8Buf wxCharBuffer +#endif + // ---------------------------------------------------------------------------- // A class for holding growable data buffers (not necessarily strings) // ---------------------------------------------------------------------------- @@ -306,9 +320,12 @@ public: wxMemoryBuffer& operator=(const wxMemoryBuffer& src) { - m_bufdata->DecRef(); - m_bufdata = src.m_bufdata; - m_bufdata->IncRef(); + if (&src != this) + { + m_bufdata->DecRef(); + m_bufdata = src.m_bufdata; + m_bufdata->IncRef(); + } return *this; }