don't call gtk_selection_data_set_text() with non-UTF-8 data as we did in ANSI build (#2037)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54742 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-07-21 03:39:40 +00:00
parent 73597f8aff
commit b82c3e606c

View File

@@ -299,29 +299,29 @@ selection_handler( GtkWidget *WXUNUSED(widget),
if (size == 0) return; if (size == 0) return;
void *d = malloc(size); wxCharBuffer buf(size);
wxON_BLOCK_EXIT1(free, d);
// Text data will be in UTF8 in Unicode mode. // text data must be returned in UTF8 if format is wxDF_UNICODETEXT
data->GetDataHere( selection_data->target, d ); data->GetDataHere( format, buf.data() );
// NB: GTK+ requires special treatment of UTF8_STRING data, the text // use UTF8_STRING format if requested in Unicode build but just plain
// would show as UTF-8 data interpreted as latin1 (?) in other // STRING one in ANSI or if explicitly asked in Unicode
// GTK+ apps if we used gtk_selection_data_set() #if wxUSE_UNICODE
if (format == wxDataFormat(wxDF_UNICODETEXT)) if (format == wxDataFormat(wxDF_UNICODETEXT))
{ {
gtk_selection_data_set_text( gtk_selection_data_set_text(
selection_data, selection_data,
(const gchar*)d, (const gchar*)buf.data(),
size ); size );
} }
else else
#endif
{ {
gtk_selection_data_set( gtk_selection_data_set(
selection_data, selection_data,
GDK_SELECTION_TYPE_STRING, GDK_SELECTION_TYPE_STRING,
8*sizeof(gchar), 8*sizeof(gchar),
(unsigned char*) d, (const guchar*)buf.data(),
size ); size );
} }
} }