diff --git a/src/common/dobjcmn.cpp b/src/common/dobjcmn.cpp index eb2d539c39..01a1a6699c 100644 --- a/src/common/dobjcmn.cpp +++ b/src/common/dobjcmn.cpp @@ -429,19 +429,15 @@ bool wxTextDataObject::SetData(size_t len, const void *buf) size_t wxHTMLDataObject::GetDataSize() const { - size_t size = 0; - // Windows and Mac always use UTF-8, and docs suggest GTK does as well. - wxCharBuffer buffer = wxConvUTF8.cWX2MB( GetHTML().c_str() ); + const wxScopedCharBuffer buffer(GetHTML().utf8_str()); + + size_t size = buffer.length(); - if (buffer) - { - size = strlen( buffer ); #ifdef __WXMSW__ - // On Windows we need to add some stuff to the string to satisfy - // its clipboard format requirements. - size += 400; + // On Windows we need to add some stuff to the string to satisfy + // its clipboard format requirements. + size += 400; #endif - } return size; } @@ -452,14 +448,14 @@ bool wxHTMLDataObject::GetDataHere(void *buf) const return false; // Windows and Mac always use UTF-8, and docs suggest GTK does as well. - wxCharBuffer html = wxConvUTF8.cWX2MB( GetHTML().c_str() ); + const wxScopedCharBuffer html(GetHTML().utf8_str()); if ( !html ) return false; - size_t bytes = GetDataSize(); + char* const buffer = static_cast(buf); + #ifdef __WXMSW__ // add the extra info that the MSW clipboard format requires. - char* buffer = new char[bytes]; // Create a template string for the HTML header... strcpy(buffer, @@ -500,11 +496,9 @@ bool wxHTMLDataObject::GetDataHere(void *buf) const sprintf(ptr+12, "%08u", (unsigned)(strstr(buffer, "", fragmentStart) + 3; int endCommentStart = html.rfind("