[gtk+] wayland: Ensure we cancel previous selection writes before starting one



commit 5e7159413d2545e3fd1454b14852f8c4f82ec0c5
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jun 24 19:57:40 2015 +0200

    wayland: Ensure we cancel previous selection writes before starting one
    
    We weren't catching all the places where the AsyncWriteData operation
    should be cancelled, which could happen if we repeatedly request the
    same target on different fds.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=751414

 gdk/wayland/gdkselection-wayland.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c
index d109562..86bfde2 100644
--- a/gdk/wayland/gdkselection-wayland.c
+++ b/gdk/wayland/gdkselection-wayland.c
@@ -466,6 +466,15 @@ gdk_wayland_selection_check_write (GdkWaylandSelection *selection)
       selection->stored_selection.data_len == 0)
     return FALSE;
 
+  /* Cancel any previous ongoing async write */
+  if (selection->stored_selection.cancellable)
+    {
+      g_cancellable_cancel (selection->stored_selection.cancellable);
+      g_object_unref (selection->stored_selection.cancellable);
+    }
+
+  selection->stored_selection.cancellable = g_cancellable_new ();
+
   write_data = async_write_data_new (selection);
   async_write_data_write (write_data);
   selection->stored_selection.fd = -1;
@@ -512,17 +521,10 @@ gdk_wayland_selection_store (GdkWindow    *window,
       g_free (selection->stored_selection.data);
     }
 
-  if (selection->stored_selection.cancellable)
-    {
-      g_cancellable_cancel (selection->stored_selection.cancellable);
-      g_object_unref (selection->stored_selection.cancellable);
-    }
-
   selection->stored_selection.source = window;
   selection->stored_selection.data_len = array->len;
   selection->stored_selection.data = (guchar *) g_array_free (array, FALSE);
   selection->stored_selection.type = type;
-  selection->stored_selection.cancellable = g_cancellable_new ();
 
   gdk_wayland_selection_check_write (selection);
 }


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