summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Rietveld <kris@gtk.org>2009-09-04 13:41:17 +0200
committerKristian Rietveld <kris@gtk.org>2009-09-04 14:06:59 +0200
commitdc3fb714a08a102c0972489afd0c566b9a17cc56 (patch)
treefa5b113fb94e148581cc2a0b89c5375687afc7b7
parent7a3d98324df08cce17ee0ffce74c0fa73b38ee4a (diff)
downloadgdk-pixbuf-dc3fb714a08a102c0972489afd0c566b9a17cc56.tar.gz
Improve unsetting old buffer in gtk_text_view_set_buffer()
When unsetting the old buffer always set the buffer on the layout to NULL. More importantly, clear the pending scroll. (The scroll is handled in an idle, when not cleared an idle handler might touch the layout later on, possibly corrupting the BTree). Unref the buffer after removing the selection from the clipboard, not before. Patch merged from maemo-gtk.
-rw-r--r--gtk/gtktextview.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index ad04480d4..72d7fe3a1 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -349,6 +349,7 @@ static GtkAdjustment* get_vadjustment (GtkTextView *text_view);
static void gtk_text_view_do_popup (GtkTextView *text_view,
GdkEventButton *event);
+static void cancel_pending_scroll (GtkTextView *text_view);
static void gtk_text_view_queue_scroll (GtkTextView *text_view,
GtkTextMark *mark,
gdouble within_margin,
@@ -1412,16 +1413,21 @@ gtk_text_view_set_buffer (GtkTextView *text_view,
g_signal_handlers_disconnect_by_func (text_view->buffer,
gtk_text_view_paste_done_handler,
text_view);
- g_object_unref (text_view->buffer);
- text_view->dnd_mark = NULL;
- text_view->first_para_mark = NULL;
if (GTK_WIDGET_REALIZED (text_view))
{
GtkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (text_view),
GDK_SELECTION_PRIMARY);
gtk_text_buffer_remove_selection_clipboard (text_view->buffer, clipboard);
- }
+ }
+
+ if (text_view->layout)
+ gtk_text_layout_set_buffer (text_view->layout, NULL);
+
+ g_object_unref (text_view->buffer);
+ text_view->dnd_mark = NULL;
+ text_view->first_para_mark = NULL;
+ cancel_pending_scroll (text_view);
}
text_view->buffer = buffer;