summaryrefslogtreecommitdiff
path: root/gobject/gobject.c
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2011-11-16 15:38:25 +0000
committerRyan Lortie <desrt@desrt.ca>2011-11-16 17:50:12 +0000
commit8215fc5f255ae499904534042ac08e221c4f5f13 (patch)
treeec10a396205960a37b2ea9e5b3fccdabdd7669cb /gobject/gobject.c
parent760037ec46bb3a8af8ea98e06a624a3ebac1cb1a (diff)
downloadglib-8215fc5f255ae499904534042ac08e221c4f5f13.tar.gz
[notify] lift some logic out of _notify_queue_add
Lift the check-if-READABLE and redirect-target logic from out of g_object_notify_queue_add() into its own function, get_notify_pspec(). Use that function at the site of our two calls to g_object_notify_queue_add().
Diffstat (limited to 'gobject/gobject.c')
-rw-r--r--gobject/gobject.c63
1 files changed, 42 insertions, 21 deletions
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 19599cb11..6cf93a3ed 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -309,26 +309,17 @@ g_object_notify_queue_add (GObject *object,
GObjectNotifyQueue *nqueue,
GParamSpec *pspec)
{
- if (pspec->flags & G_PARAM_READABLE)
- {
- GParamSpec *redirect;
-
- redirect = g_param_spec_get_redirect_target (pspec);
- if (redirect)
- pspec = redirect;
-
- G_LOCK(notify_lock);
+ G_LOCK(notify_lock);
- g_return_if_fail (nqueue->n_pspecs < 65535);
+ g_return_if_fail (nqueue->n_pspecs < 65535);
- if (g_slist_find (nqueue->pspecs, pspec) == NULL)
- {
- nqueue->pspecs = g_slist_prepend (nqueue->pspecs, pspec);
- nqueue->n_pspecs++;
- }
-
- G_UNLOCK(notify_lock);
+ if (g_slist_find (nqueue->pspecs, pspec) == NULL)
+ {
+ nqueue->pspecs = g_slist_prepend (nqueue->pspecs, pspec);
+ nqueue->n_pspecs++;
}
+
+ G_UNLOCK(notify_lock);
}
static void
@@ -1094,15 +1085,39 @@ g_object_freeze_notify (GObject *object)
g_object_unref (object);
}
+static GParamSpec *
+get_notify_pspec (GParamSpec *pspec)
+{
+ GParamSpec *redirected;
+
+ /* we don't notify on non-READABLE parameters */
+ if (~pspec->flags & G_PARAM_READABLE)
+ return NULL;
+
+ /* if the paramspec is redirected, notify on the target */
+ redirected = g_param_spec_get_redirect_target (pspec);
+ if (redirected != NULL)
+ return redirected;
+
+ /* else, notify normally */
+ return pspec;
+}
+
static inline void
g_object_notify_by_spec_internal (GObject *object,
GParamSpec *pspec)
{
GObjectNotifyQueue *nqueue;
+ GParamSpec *notify_pspec;
- nqueue = g_object_notify_queue_freeze (object, &property_notify_context);
- g_object_notify_queue_add (object, nqueue, pspec);
- g_object_notify_queue_thaw (object, nqueue);
+ notify_pspec = get_notify_pspec (pspec);
+
+ if (notify_pspec != NULL)
+ {
+ nqueue = g_object_notify_queue_freeze (object, &property_notify_context);
+ g_object_notify_queue_add (object, nqueue, notify_pspec);
+ g_object_notify_queue_thaw (object, nqueue);
+ }
}
/**
@@ -1318,8 +1333,14 @@ object_set_property (GObject *object,
}
else
{
+ GParamSpec *notify_pspec;
+
class->set_property (object, param_id, &tmp_value, pspec);
- g_object_notify_queue_add (object, nqueue, pspec);
+
+ notify_pspec = get_notify_pspec (pspec);
+
+ if (notify_pspec != NULL)
+ g_object_notify_queue_add (object, nqueue, notify_pspec);
}
g_value_unset (&tmp_value);
}