mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-27 14:36:16 +01:00
Add a check that no properties are added after a class is derived
We can't support that, because that would cause the CLASS_HAS_PROPS_FLAG class flag to not be correct.
This commit is contained in:
parent
39a1fe5782
commit
302d13a757
@ -117,6 +117,10 @@
|
|||||||
#define CLASS_HAS_PROPS(class) \
|
#define CLASS_HAS_PROPS(class) \
|
||||||
((class)->flags & CLASS_HAS_PROPS_FLAG)
|
((class)->flags & CLASS_HAS_PROPS_FLAG)
|
||||||
|
|
||||||
|
#define CLASS_HAS_DERIVED_CLASS_FLAG 0x2
|
||||||
|
#define CLASS_HAS_DERIVED_CLASS(class) \
|
||||||
|
((class)->flags & CLASS_HAS_DERIVED_CLASS_FLAG)
|
||||||
|
|
||||||
/* --- signals --- */
|
/* --- signals --- */
|
||||||
enum {
|
enum {
|
||||||
NOTIFY,
|
NOTIFY,
|
||||||
@ -280,6 +284,12 @@ g_object_base_class_init (GObjectClass *class)
|
|||||||
{
|
{
|
||||||
GObjectClass *pclass = g_type_class_peek_parent (class);
|
GObjectClass *pclass = g_type_class_peek_parent (class);
|
||||||
|
|
||||||
|
/* Don't inherit HAS_DERIVED_CLASS flag from parent class */
|
||||||
|
class->flags &= ~CLASS_HAS_DERIVED_CLASS_FLAG;
|
||||||
|
|
||||||
|
if (pclass)
|
||||||
|
pclass->flags |= CLASS_HAS_DERIVED_CLASS_FLAG;
|
||||||
|
|
||||||
/* reset instance specific fields and methods that don't get inherited */
|
/* reset instance specific fields and methods that don't get inherited */
|
||||||
class->construct_properties = pclass ? g_slist_copy (pclass->construct_properties) : NULL;
|
class->construct_properties = pclass ? g_slist_copy (pclass->construct_properties) : NULL;
|
||||||
class->get_property = NULL;
|
class->get_property = NULL;
|
||||||
@ -413,6 +423,10 @@ g_object_class_install_property (GObjectClass *class,
|
|||||||
g_return_if_fail (G_IS_OBJECT_CLASS (class));
|
g_return_if_fail (G_IS_OBJECT_CLASS (class));
|
||||||
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
|
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
|
||||||
|
|
||||||
|
if (CLASS_HAS_DERIVED_CLASS (class))
|
||||||
|
g_error ("Attempt to add property %s::%s to class after it was derived",
|
||||||
|
G_OBJECT_CLASS_NAME (class), pspec->name);
|
||||||
|
|
||||||
class->flags |= CLASS_HAS_PROPS_FLAG;
|
class->flags |= CLASS_HAS_PROPS_FLAG;
|
||||||
|
|
||||||
if (pspec->flags & G_PARAM_WRITABLE)
|
if (pspec->flags & G_PARAM_WRITABLE)
|
||||||
|
Loading…
Reference in New Issue
Block a user