[glib/ebassi/dispose-notify: 1/2] Add a function to drain the notification queue




commit 9674edf77474e3fdd263001431a5ede84d8e60b7
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sun Nov 28 00:36:06 2021 +0000

    Add a function to drain the notification queue
    
    Equivalent of g_object_notify_thaw(), but instead of dispatching the
    pending notifications, it just drains the notification queue.

 gobject/gobject.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 1c95e3d0d..33db8090c 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -349,6 +349,34 @@ g_object_notify_queue_thaw (GObject            *object,
   g_free (free_me);
 }
 
+static void
+g_object_notify_queue_drain (GObject            *object
+                             GObjectNotifyQueue *nqueue)
+{
+  GSList *slist;
+  guint n_pspecs = 0;
+
+  g_return_if_fail (g_atomic_int_get (&object->ref_count) > 0);
+
+  G_LOCK (notify_lock);
+
+  /* Just make sure we never get into some nasty race condition */
+  if (G_UNLIKELY (nqueue->freeze_count == 0))
+    {
+      G_UNLOCK (notify_lock);
+      g_warning ("%s: property-changed notification for %s(%p) is not frozen",
+                 G_STRFUNC, G_OBJECT_TYPE_NAME (object), object);
+      return;
+    }
+
+  nqueue->freeze_count--;
+
+  if (nqueue->freeze_count == 0)
+    g_datalist_id_set_data (&object->qdata, quark_notify_queue, NULL);
+
+  G_UNLOCK (notify_lock);
+}
+
 static void
 g_object_notify_queue_add (GObject            *object,
                            GObjectNotifyQueue *nqueue,


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