[gtk] x11: Make sure stream stays alive long enough



commit 96b782c026fe026dda0b2c61dcb7cb50f4aa828c
Author: Benjamin Otte <otte redhat com>
Date:   Fri Jul 5 20:55:54 2019 +0200

    x11: Make sure stream stays alive long enough
    
    When unreffing the stream from a different thread, the close function
    will schedule its cleanup asynchornously in the main thread.
    We need to make sure the stream object stays alive for as long as
    that hasn't happened, so ref() it.
    
    Fixes #2003

 gdk/x11/gdkselectionoutputstream-x11.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gdk/x11/gdkselectionoutputstream-x11.c b/gdk/x11/gdkselectionoutputstream-x11.c
index c43e513ab3..63d1c33d17 100644
--- a/gdk/x11/gdkselectionoutputstream-x11.c
+++ b/gdk/x11/gdkselectionoutputstream-x11.c
@@ -503,6 +503,7 @@ gdk_x11_selection_output_stream_invoke_close (gpointer stream)
   g_signal_handlers_disconnect_by_func (priv->display,
                                         gdk_x11_selection_output_stream_xevent,
                                         stream);
+  g_object_unref (stream);
 
   return G_SOURCE_REMOVE;
 }
@@ -512,7 +513,7 @@ gdk_x11_selection_output_stream_close (GOutputStream  *stream,
                                        GCancellable   *cancellable,
                                        GError        **error)
 {
-  g_main_context_invoke (NULL, gdk_x11_selection_output_stream_invoke_close, stream);
+  g_main_context_invoke (NULL, gdk_x11_selection_output_stream_invoke_close, g_object_ref (stream));
 
   return TRUE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]