From: Marco Trevisan (TreviƱo) Date: Tue, 30 May 2023 15:59:06 +0000 (+0200) Subject: gdkselectioninputstream-x11: Explicitly handle stream ownership in signal X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~201^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=be4f6ff3dad7adce085a95ca652dda31a20a00d4;p=gtk4.git gdkselectioninputstream-x11: Explicitly handle stream ownership in signal The display xevent signal connection takes the ownership of the stream until we get a valid event, so it should manage the stream lifetime. So make this clearer, by automatically removing the stream reference when we disconnect from the xevent signal handler. --- diff --git a/gdk/x11/gdkselectioninputstream-x11.c b/gdk/x11/gdkselectioninputstream-x11.c index e62bd96035..6682639f44 100644 --- a/gdk/x11/gdkselectioninputstream-x11.c +++ b/gdk/x11/gdkselectioninputstream-x11.c @@ -165,9 +165,7 @@ gdk_x11_selection_input_stream_complete (GdkX11SelectionInputStream *stream) GDK_X11_DISPLAY (priv->display)->streams = g_slist_remove (GDK_X11_DISPLAY (priv->display)->streams, stream); g_signal_handlers_disconnect_by_func (priv->display, gdk_x11_selection_input_stream_xevent, - stream); - - g_object_unref (stream); + g_steal_pointer (&stream)); } static gssize @@ -541,7 +539,10 @@ gdk_x11_selection_input_stream_new_async (GdkDisplay *display, priv->property = g_strdup_printf ("GDK_SELECTION_%p", stream); priv->xproperty = gdk_x11_get_xatom_by_name_for_display (display, priv->property); - g_signal_connect (display, "xevent", G_CALLBACK (gdk_x11_selection_input_stream_xevent), stream); + g_signal_connect_data (display, "xevent", + G_CALLBACK (gdk_x11_selection_input_stream_xevent), + g_steal_pointer (&stream), + (GClosureNotify) g_object_unref, 0); XConvertSelection (GDK_DISPLAY_XDISPLAY (display), priv->xselection,