diff options
author | Timm Bäder <mail@baedert.org> | 2020-09-19 18:41:10 +0200 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2020-09-24 19:08:22 +0200 |
commit | 12cc178756b285fd3c5922d3436b45ffe72793bb (patch) | |
tree | cc6bb6e1355d75bf9c3b3d37f864a2c78fe8540d /gtk/gtktextbuffer.c | |
parent | 9eaa8bd1e71bff7112819500ee5c4966d3deed5c (diff) | |
download | gtk+-12cc178756b285fd3c5922d3436b45ffe72793bb.tar.gz |
textbuffer: Don't try to inset NULL text from clipboard
That used to generate a critical error message.
Also free() the data.
Diffstat (limited to 'gtk/gtktextbuffer.c')
-rw-r--r-- | gtk/gtktextbuffer.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index 854799d8a8..18861d301c 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -310,6 +310,7 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source, GtkTextIter start, end; GError *error = NULL; gssize written; + char *data; written = g_output_stream_splice_finish (stream, result, &error); if (written < 0) @@ -318,15 +319,19 @@ gtk_text_buffer_deserialize_text_plain_finish (GObject *source, return; } - buffer = g_value_get_object (gdk_content_deserializer_get_value (deserializer)); - gtk_text_buffer_get_end_iter (buffer, &end); - gtk_text_buffer_insert (buffer, - &end, - g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM ( - g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream)))), - -1); - gtk_text_buffer_get_bounds (buffer, &start, &end); - gtk_text_buffer_select_range (buffer, &start, &end); + data = g_memory_output_stream_steal_data (G_MEMORY_OUTPUT_STREAM ( + g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (stream)))); + + if (data) + { + buffer = g_value_get_object (gdk_content_deserializer_get_value (deserializer)); + gtk_text_buffer_get_end_iter (buffer, &end); + gtk_text_buffer_insert (buffer, &end, data, -1); + gtk_text_buffer_get_bounds (buffer, &start, &end); + gtk_text_buffer_select_range (buffer, &start, &end); + + g_free (data); + } gdk_content_deserializer_return_success (deserializer); } |