From: Alexander Larsson Date: Fri, 2 Oct 2009 17:27:48 +0000 (+0200) Subject: Add a check that no properties are added after a class is derived X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=302d13a757c164346883841ce040208906894b71;p=dana%2Fcg-glib.git 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. --- diff --git a/gobject/gobject.c b/gobject/gobject.c index d7d5d560..51403314 100644 --- a/gobject/gobject.c +++ b/gobject/gobject.c @@ -117,6 +117,10 @@ #define CLASS_HAS_PROPS(class) \ ((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 --- */ enum { NOTIFY, @@ -280,6 +284,12 @@ g_object_base_class_init (GObjectClass *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 */ class->construct_properties = pclass ? g_slist_copy (pclass->construct_properties) : 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_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; if (pspec->flags & G_PARAM_WRITABLE)