[glib/freeze-shenanigans] Handle notify freezing with custom constructors
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/freeze-shenanigans] Handle notify freezing with custom constructors
- Date: Fri, 10 Jun 2022 00:13:31 +0000 (UTC)
commit 96bacd1d09e5ad90d30138560c8cc76c4b52e077
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Jun 9 20:11:50 2022 -0400
Handle notify freezing with custom constructors
g_object_new_with_custom_constructor needs to handle
freezing notifications in the same way as
g_object_new_internal.
Fixing a bug pointed out by Christian Hergert.
gobject/gobject.c | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
---
diff --git a/gobject/gobject.c b/gobject/gobject.c
index 7b402eba67..039a622deb 100644
--- a/gobject/gobject.c
+++ b/gobject/gobject.c
@@ -2132,28 +2132,15 @@ g_object_new_with_custom_constructor (GObjectClass *class,
if (CLASS_HAS_PROPS (class))
{
- /* If this object was newly_constructed then g_object_init()
- * froze the queue. We need to freeze it here in order to get
- * the handle so that we can thaw it below (otherwise it will
- * be frozen forever).
- *
- * We also want to do a freeze if we have any params to set,
- * even on a non-newly_constructed object.
- *
- * It's possible that we have the case of non-newly created
- * singleton and all of the passed-in params were construct
- * properties so n_params > 0 but we will actually set no
- * properties. This is a pretty lame case to optimise, so
- * just ignore it and freeze anyway.
- */
- if (newly_constructed || n_params)
- nqueue = g_object_notify_queue_freeze (object, FALSE);
-
- /* Remember: if it was newly_constructed then g_object_init()
- * already did a freeze, so we now have two. Release one.
- */
- if (newly_constructed)
- g_object_notify_queue_thaw (object, nqueue);
+ if (_g_object_has_notify_handler (object))
+ {
+ /* 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, FALSE);
+ }
}
/* run 'constructed' handler if there is a custom one */
@@ -2196,7 +2183,9 @@ g_object_new_internal (GObjectClass *class,
if (_g_object_has_notify_handler (object))
{
- /* This will have been setup in g_object_init() */
+ /* 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, FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]