diff --git a/gobject/gobject.c b/gobject/gobject.c index 93569f994..cc0f417d9 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -687,8 +687,7 @@ g_object_notify_queue_freeze_cb (gpointer *data, if (!nqueue) { /* The nqueue doesn't exist yet. We create it, and freeze thus 1 time. */ - nqueue = g_object_notify_queue_new_frozen (); - *data = nqueue; + *data = g_object_notify_queue_new_frozen (); *destroy_notify = g_free; } else @@ -704,16 +703,16 @@ g_object_notify_queue_freeze_cb (gpointer *data, nqueue->freeze_count++; } - return nqueue; + return NULL; } -static GObjectNotifyQueue * +static void g_object_notify_queue_freeze (GObject *object) { - return _g_datalist_id_update_atomic (&object->qdata, - quark_notify_queue, - g_object_notify_queue_freeze_cb, - object); + _g_datalist_id_update_atomic (&object->qdata, + quark_notify_queue, + g_object_notify_queue_freeze_cb, + object); } static gpointer @@ -741,10 +740,10 @@ g_object_notify_queue_thaw_cb (gpointer *data, } static void -g_object_notify_queue_thaw (GObject *object, - GObjectNotifyQueue *nqueue, - gboolean take_ref) +g_object_notify_queue_thaw (GObject *object, gboolean take_ref) { + GObjectNotifyQueue *nqueue; + nqueue = _g_datalist_id_update_atomic (&object->qdata, quark_notify_queue, g_object_notify_queue_thaw_cb, @@ -846,7 +845,6 @@ out: static gboolean g_object_notify_queue_add (GObject *object, - GObjectNotifyQueue *nqueue, GParamSpec *pspec, gboolean in_init) { @@ -1985,7 +1983,7 @@ g_object_notify_by_spec_internal (GObject *object, if (pspec != NULL && needs_notify) { - if (!g_object_notify_queue_add (object, NULL, pspec, in_init)) + if (!g_object_notify_queue_add (object, pspec, in_init)) { /* * Coverity doesn’t understand the paired ref/unref here and seems to @@ -2138,7 +2136,7 @@ g_object_thaw_notify (GObject *object) } #endif - g_object_notify_queue_thaw (object, NULL, TRUE); + g_object_notify_queue_thaw (object, TRUE); } static void @@ -2211,7 +2209,7 @@ static inline void object_set_property (GObject *object, GParamSpec *pspec, const GValue *value, - GObjectNotifyQueue *nqueue, + gboolean nqueue_is_frozen, gboolean user_specified) { GTypeInstance *inst = (GTypeInstance *) object; @@ -2270,8 +2268,8 @@ object_set_property (GObject *object, } if ((pspec->flags & (G_PARAM_EXPLICIT_NOTIFY | G_PARAM_READABLE)) == G_PARAM_READABLE && - nqueue != NULL) - g_object_notify_queue_add (object, nqueue, pspec, FALSE); + nqueue_is_frozen) + g_object_notify_queue_add (object, pspec, FALSE); } static void @@ -2515,7 +2513,7 @@ g_object_new_with_custom_constructor (GObjectClass *class, GObjectConstructParam *params, guint n_params) { - GObjectNotifyQueue *nqueue = NULL; + gboolean nqueue_is_frozen = FALSE; gboolean newly_constructed; GObjectConstructParam *cparams; gboolean free_cparams = FALSE; @@ -2638,9 +2636,9 @@ g_object_new_with_custom_constructor (GObjectClass *class, /* This may or may not have been setup in g_object_init(). * If it hasn't, we do it now. */ - nqueue = g_datalist_id_get_data (&object->qdata, quark_notify_queue); - if (!nqueue) - nqueue = g_object_notify_queue_freeze (object); + if (!g_datalist_id_get_data (&object->qdata, quark_notify_queue)) + g_object_notify_queue_freeze (object); + nqueue_is_frozen = TRUE; } } @@ -2651,11 +2649,10 @@ g_object_new_with_custom_constructor (GObjectClass *class, /* set remaining properties */ for (i = 0; i < n_params; i++) if (!(params[i].pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))) - object_set_property (object, params[i].pspec, params[i].value, nqueue, TRUE); + object_set_property (object, params[i].pspec, params[i].value, nqueue_is_frozen, TRUE); - /* If nqueue is non-NULL then we are frozen. Thaw it. */ - if (nqueue) - g_object_notify_queue_thaw (object, nqueue, FALSE); + if (nqueue_is_frozen) + g_object_notify_queue_thaw (object, FALSE); return object; } @@ -2665,7 +2662,7 @@ g_object_new_internal (GObjectClass *class, GObjectConstructParam *params, guint n_params) { - GObjectNotifyQueue *nqueue = NULL; + gboolean nqueue_is_frozen = FALSE; GObject *object; guint i; @@ -2687,9 +2684,9 @@ g_object_new_internal (GObjectClass *class, /* This may or may not have been setup in g_object_init(). * If it hasn't, we do it now. */ - nqueue = g_datalist_id_get_data (&object->qdata, quark_notify_queue); - if (!nqueue) - nqueue = g_object_notify_queue_freeze (object); + if (!g_datalist_id_get_data (&object->qdata, quark_notify_queue)) + g_object_notify_queue_freeze (object); + nqueue_is_frozen = TRUE; } /* We will set exactly n_construct_properties construct @@ -2717,7 +2714,7 @@ g_object_new_internal (GObjectClass *class, if (value == NULL) value = g_param_spec_get_default_value (pspec); - object_set_property (object, pspec, value, nqueue, user_specified); + object_set_property (object, pspec, value, nqueue_is_frozen, user_specified); } } @@ -2730,10 +2727,10 @@ g_object_new_internal (GObjectClass *class, */ for (i = 0; i < n_params; i++) if (!(params[i].pspec->flags & (G_PARAM_CONSTRUCT | G_PARAM_CONSTRUCT_ONLY))) - object_set_property (object, params[i].pspec, params[i].value, nqueue, TRUE); + object_set_property (object, params[i].pspec, params[i].value, nqueue_is_frozen, TRUE); - if (nqueue) - g_object_notify_queue_thaw (object, nqueue, FALSE); + if (nqueue_is_frozen) + g_object_notify_queue_thaw (object, FALSE); return object; } @@ -3052,7 +3049,7 @@ g_object_constructor (GType type, /* set construction parameters */ if (n_construct_properties) { - GObjectNotifyQueue *nqueue = g_object_notify_queue_freeze (object); + g_object_notify_queue_freeze (object); /* set construct properties */ while (n_construct_properties--) @@ -3061,9 +3058,10 @@ g_object_constructor (GType type, GParamSpec *pspec = construct_params->pspec; construct_params++; - object_set_property (object, pspec, value, nqueue, FALSE); + object_set_property (object, pspec, value, TRUE, FALSE); } - g_object_notify_queue_thaw (object, nqueue, FALSE); + + g_object_notify_queue_thaw (object, FALSE); /* the notification queue is still frozen from g_object_init(), so * we don't need to handle it here, g_object_newv() takes * care of that @@ -3126,7 +3124,7 @@ g_object_setv (GObject *object, const GValue values[]) { guint i; - GObjectNotifyQueue *nqueue = NULL; + gboolean nqueue_is_frozen = FALSE; GParamSpec *pspec; GObjectClass *class; @@ -3140,7 +3138,10 @@ g_object_setv (GObject *object, class = G_OBJECT_GET_CLASS (object); if (_g_object_has_notify_handler (object)) - nqueue = g_object_notify_queue_freeze (object); + { + g_object_notify_queue_freeze (object); + nqueue_is_frozen = TRUE; + } for (i = 0; i < n_properties; i++) { @@ -3149,11 +3150,11 @@ g_object_setv (GObject *object, if (!g_object_set_is_valid_property (object, pspec, names[i])) break; - object_set_property (object, pspec, &values[i], nqueue, TRUE); + object_set_property (object, pspec, &values[i], nqueue_is_frozen, TRUE); } - if (nqueue) - g_object_notify_queue_thaw (object, nqueue, FALSE); + if (nqueue_is_frozen) + g_object_notify_queue_thaw (object, FALSE); g_object_unref (object); } @@ -3172,7 +3173,7 @@ g_object_set_valist (GObject *object, const gchar *first_property_name, va_list var_args) { - GObjectNotifyQueue *nqueue = NULL; + gboolean nqueue_is_frozen = FALSE; const gchar *name; GObjectClass *class; @@ -3181,7 +3182,10 @@ g_object_set_valist (GObject *object, g_object_ref (object); if (_g_object_has_notify_handler (object)) - nqueue = g_object_notify_queue_freeze (object); + { + g_object_notify_queue_freeze (object); + nqueue_is_frozen = TRUE; + } class = G_OBJECT_GET_CLASS (object); @@ -3207,7 +3211,7 @@ g_object_set_valist (GObject *object, break; } - object_set_property (object, pspec, &value, nqueue, TRUE); + object_set_property (object, pspec, &value, nqueue_is_frozen, TRUE); /* We open-code g_value_unset() here to avoid the * cost of looking up the GTypeValueTable again. @@ -3218,8 +3222,8 @@ g_object_set_valist (GObject *object, name = va_arg (var_args, gchar*); } - if (nqueue) - g_object_notify_queue_thaw (object, nqueue, FALSE); + if (nqueue_is_frozen) + g_object_notify_queue_thaw (object, FALSE); g_object_unref (object); } @@ -4426,7 +4430,7 @@ g_object_unref (gpointer _object) gint old_ref; GToggleNotify toggle_notify; gpointer toggle_data; - GObjectNotifyQueue *nqueue; + gboolean nqueue_is_frozen; GType obj_gtype; g_return_if_fail (G_IS_OBJECT (object)); @@ -4514,7 +4518,8 @@ retry_beginning: * which happens to be the same lock that is also taken by toggle_refs_check_and_ref(), * that is very important. See also the code comment in toggle_refs_check_and_ref(). */ - nqueue = g_object_notify_queue_freeze (object); + g_object_notify_queue_freeze (object); + nqueue_is_frozen = TRUE; TRACE (GOBJECT_OBJECT_DISPOSE (object, G_TYPE_FROM_INSTANCE (object), 1)); G_OBJECT_GET_CLASS (object)->dispose (object); @@ -4528,12 +4533,12 @@ retry_decrement: /* Here, old_ref is 1 if we just come from dispose(). If the object was resurrected, * we can hit `goto retry_decrement` and be here with a larger old_ref. */ - if (old_ref > 1 && nqueue) + if (old_ref > 1 && nqueue_is_frozen) { /* If the object was resurrected, we need to unfreeze the notify * queue. */ - g_object_notify_queue_thaw (object, nqueue, FALSE); - nqueue = NULL; + g_object_notify_queue_thaw (object, FALSE); + nqueue_is_frozen = FALSE; /* Note at this point, @old_ref might be wrong. *