mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-06-02 19:00:08 +02:00
gobject: set flags without atomic during constructions
We are still very early. Initialize the flags without an atomic. Note that we also: - above initialize object->ref_count without atomic. - we called atomic operation set_object_in_construction(), which sets certain flags, but relies on the other flags being initialized correctly (they are not touched by g_atomic_int_or()). Those other flags are also initialized without atomic, relying on being memset() to zero.
This commit is contained in:
parent
c5a6a21071
commit
0d596bab12
@ -1793,12 +1793,6 @@ object_in_construction (GObject *object)
|
||||
return (object_get_optional_flags (object) & OPTIONAL_FLAG_IN_CONSTRUCTION) != 0;
|
||||
}
|
||||
|
||||
static inline void
|
||||
set_object_in_construction (GObject *object)
|
||||
{
|
||||
object_set_optional_flags (object, OPTIONAL_FLAG_IN_CONSTRUCTION);
|
||||
}
|
||||
|
||||
static inline void
|
||||
unset_object_in_construction (GObject *object)
|
||||
{
|
||||
@ -1809,18 +1803,22 @@ static void
|
||||
g_object_init (GObject *object,
|
||||
GObjectClass *class)
|
||||
{
|
||||
guint *p_flags;
|
||||
|
||||
object->ref_count = 1;
|
||||
object->qdata = NULL;
|
||||
|
||||
/* We are still very early during construction. At this point we set the flag
|
||||
* without atomic. */
|
||||
p_flags = object_get_optional_flags_p (object);
|
||||
*p_flags = OPTIONAL_FLAG_IN_CONSTRUCTION;
|
||||
|
||||
if (CLASS_HAS_PROPS (class) && CLASS_NEEDS_NOTIFY (class))
|
||||
{
|
||||
/* freeze object's notification queue, g_object_new_internal() preserves pairedness */
|
||||
g_object_notify_queue_freeze (object, TRUE);
|
||||
}
|
||||
|
||||
/* mark object in-construction for notify_queue_thaw() and to allow construct-only properties */
|
||||
set_object_in_construction (object);
|
||||
|
||||
GOBJECT_IF_DEBUG (OBJECTS,
|
||||
{
|
||||
G_LOCK (debug_objects);
|
||||
|
Loading…
x
Reference in New Issue
Block a user