From 1b8cb9ac5957131d85ddea669c066a355de967f5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 21 Jul 2008 03:39:40 +0000 Subject: [PATCH] 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/branches/WX_2_8_BRANCH@54742 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/gtk/clipbrd.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/gtk/clipbrd.cpp b/src/gtk/clipbrd.cpp index 0067d971bc..8fd6facbd7 100644 --- a/src/gtk/clipbrd.cpp +++ b/src/gtk/clipbrd.cpp @@ -282,11 +282,14 @@ selection_handler( GtkWidget *WXUNUSED(widget), if (size == 0) return; - void *d = malloc(size); + wxCharBuffer buf(size); - // Text data will be in UTF8 in Unicode mode. - data->GetDataHere( selection_data->target, d ); + // text data must be returned in UTF8 if format is wxDF_UNICODETEXT + data->GetDataHere( format, buf.data() ); + // use UTF8_STRING format if requested in Unicode build but just plain + // STRING one in ANSI or if explicitly asked in Unicode +#if wxUSE_UNICODE // NB: GTK+ requires special treatment of UTF8_STRING data, the text // would show as UTF-8 data interpreted as latin1 (?) in other // GTK+ apps if we used gtk_selection_data_set() @@ -294,20 +297,19 @@ selection_handler( GtkWidget *WXUNUSED(widget), { gtk_selection_data_set_text( selection_data, - (const gchar*)d, + (const gchar*)buf.data(), size ); } else +#endif // wxUSE_UNICODE { gtk_selection_data_set( selection_data, GDK_SELECTION_TYPE_STRING, 8*sizeof(gchar), - (unsigned char*) d, + (const guchar*)buf.data(), size ); } - - free(d); } }