GObject always calls set_property on construct-only properties

Hi,

I noticed that GObject always calls set_property() on CONSTRUCT_ONLY properties, even when no values were provided by the user when calling g_object_new() or similar constructors.

Just by curiosity, is there a rationale behind this?

GObject always sets construct/construct-only properties to their default values (as specified in the GParamSpec) unless those properties were passed to g_object_new(). This allows objects to deal with default states: you can use GObjectClass.constructor() or GObjectClass.constructed() to validate that the construction state is correct, or to provide a default state in case the caller did not pass all construction properties. Remember: g_object_new() cannot fail, so construction must result in a valid object.

Oh, OK, so that allows to check attributes consistency, something we can’t do in the object’s init().
Makes sense.

Thank you!