mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 12:25:48 +01:00
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.
This commit is contained in:
parent
dccab10d9f
commit
b92f1fcbc5
@ -2132,28 +2132,15 @@ g_object_new_with_custom_constructor (GObjectClass *class,
|
|||||||
|
|
||||||
if (CLASS_HAS_PROPS (class))
|
if (CLASS_HAS_PROPS (class))
|
||||||
{
|
{
|
||||||
/* If this object was newly_constructed then g_object_init()
|
if (_g_object_has_notify_handler (object))
|
||||||
* 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
|
/* This may or may not have been setup in g_object_init().
|
||||||
* be frozen forever).
|
* If it hasn't, we do it now.
|
||||||
*
|
*/
|
||||||
* We also want to do a freeze if we have any params to set,
|
nqueue = g_datalist_id_get_data (&object->qdata, quark_notify_queue);
|
||||||
* even on a non-newly_constructed object.
|
if (!nqueue)
|
||||||
*
|
nqueue = g_object_notify_queue_freeze (object, FALSE);
|
||||||
* 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 && CLASS_HAS_NOTIFY (class))
|
|
||||||
g_object_notify_queue_thaw (object, nqueue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* run 'constructed' handler if there is a custom one */
|
/* 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))
|
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);
|
nqueue = g_datalist_id_get_data (&object->qdata, quark_notify_queue);
|
||||||
if (!nqueue)
|
if (!nqueue)
|
||||||
nqueue = g_object_notify_queue_freeze (object, FALSE);
|
nqueue = g_object_notify_queue_freeze (object, FALSE);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user