[gtk/wip/otte/for-main: 1/4] x11: Keep a reference to the SelectionOutputStream while writing




commit 645d4807c3ab0b6ac20cb08f16f39893a95bd2f2
Author: Benjamin Otte <otte redhat com>
Date:   Mon Dec 13 01:41:04 2021 +0100

    x11: Keep a reference to the SelectionOutputStream while writing
    
    This ensures close() isn't called from dispose() while we're still busy
    writing.
    
    In theory this should never happen, but in practice it just did.

 gdk/x11/gdkselectionoutputstream-x11.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
diff --git a/gdk/x11/gdkselectionoutputstream-x11.c b/gdk/x11/gdkselectionoutputstream-x11.c
index b9aad4c3f3..7b45638dd3 100644
--- a/gdk/x11/gdkselectionoutputstream-x11.c
+++ b/gdk/x11/gdkselectionoutputstream-x11.c
@@ -57,7 +57,7 @@ struct _GdkX11SelectionOutputStreamPrivate {
   GTask *pending_task;
 
   guint incr : 1;
-  guint delete_pending : 1;
+  guint delete_pending : 1; /* owns a reference */
 };
 
 struct _GdkX11PendingSelectionNotify
@@ -292,6 +292,7 @@ gdk_x11_selection_output_stream_perform_flush (GdkX11SelectionOutputStream *stre
       priv->notify = NULL;
     }
 
+  g_object_ref (stream);
   priv->delete_pending = TRUE;
   g_cond_broadcast (&priv->cond);
   g_mutex_unlock (&priv->mutex);
@@ -628,6 +629,7 @@ gdk_x11_selection_output_stream_xevent (GdkDisplay   *display,
       if (gdk_x11_selection_output_stream_needs_flush (stream) &&
           gdk_x11_selection_output_stream_can_flush (stream))
         gdk_x11_selection_output_stream_perform_flush (stream);
+      g_object_unref (stream); /* from unsetting the delete_pending */
       return FALSE;
 
     default:


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