diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c index 33f52c3f1..85325b1cc 100644 --- a/gtk/gtkselection.c +++ b/gtk/gtkselection.c @@ -2721,6 +2721,7 @@ gboolean _gtk_selection_notify (GtkWidget *widget, GdkEventSelection *event) { + GdkWindow *window; GList *tmp_list; GtkRetrievalInfo *info = NULL; guchar *buffer = NULL; @@ -2745,6 +2746,8 @@ _gtk_selection_notify (GtkWidget *widget, if (!tmp_list) /* no retrieval in progress */ return FALSE; + window = g_object_ref (widget->window); + if (event->property != GDK_NONE) length = gdk_selection_property_get (widget->window, &buffer, &type, &format); @@ -2758,6 +2761,7 @@ _gtk_selection_notify (GtkWidget *widget, /* structure will be freed in timeout */ gtk_selection_retrieval_report (info, GDK_NONE, 0, NULL, -1, event->time); + g_object_unref (window); return TRUE; } @@ -2786,7 +2790,11 @@ _gtk_selection_notify (GtkWidget *widget, buffer, length, event->time); } - gdk_property_delete (widget->window, event->property); + /* the window held, as the callback may have destroyed the widget (the + * clipboard does so with the widgets of requests that ran at the same + * time as another) */ + gdk_property_delete (window, event->property); + g_object_unref (window); g_free (buffer);