[glib] notify: Refactor g_object_notify_queue_thaw()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] notify: Refactor g_object_notify_queue_thaw()
- Date: Thu, 22 Jul 2010 20:00:59 +0000 (UTC)
commit 83026092eba98c2e6e0a96112555f980382a99e7
Author: Olivier Crête <olivier crete collabora co uk>
Date: Thu Jul 22 20:25:00 2010 +0200
notify: Refactor g_object_notify_queue_thaw()
This adds better error reporting and simplifies the code for adding
thread safety.
https://bugzilla.gnome.org/show_bug.cgi?id=166020
gobject/gobjectnotifyqueue.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gobject/gobjectnotifyqueue.c b/gobject/gobjectnotifyqueue.c
index fe82831..8492b47 100644
--- a/gobject/gobjectnotifyqueue.c
+++ b/gobject/gobjectnotifyqueue.c
@@ -96,11 +96,19 @@ g_object_notify_queue_thaw (GObject *object,
guint n_pspecs = 0;
g_return_if_fail (nqueue->freeze_count > 0);
+ g_return_if_fail (g_atomic_int_get(&object->ref_count) > 0);
+
+ /* Just make sure we never get into some nasty race condition */
+ if (G_UNLIKELY(nqueue->freeze_count == 0)) {
+ 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)
+ if (nqueue->freeze_count) {
return;
- g_return_if_fail (object->ref_count > 0);
+ }
pspecs = nqueue->n_pspecs > 16 ? free_me = g_new (GParamSpec*, nqueue->n_pspecs) : pspecs_mem;
/* set first entry to NULL since it's checked unconditionally */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]