selection: no critical when the callback of a retrieval destroys its widget, as the clipboard does with the widgets of requests that run at the same time

This commit is contained in:
Daemonratte 2026-10-18 17:59:34 +02:00
commit 4f99a52c7e
No known key found for this signature in database

View file

@ -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);