GObject: turn add-property-after-init to a warning
authorRyan Lortie <desrt@desrt.ca>
Mon, 10 Jun 2013 15:14:17 +0000 (11:14 -0400)
committerRyan Lortie <desrt@desrt.ca>
Mon, 10 Jun 2013 15:18:06 +0000 (11:18 -0400)
We have turned up enough cases of this being done (including GTK API
allowing apps to do this to GtkSettings well after it has been
instantiated) that it is clear that we cannot really break this feature
while claiming to be backwards compatible.

For that reason, it becomes a warning rather than a critical (ie: it is
still well-defined behaviour, but you are discouraged from doing it).

The intention is to keep this feature for at least the next while.
A given GObjectClass will be able to avoid using GParamSpec pool for as
long as you don't install properties after init.  If you do that, you
will get a warning and we will devolve to using GParamSpecPool.

https://bugzilla.gnome.org/show_bug.cgi?id=698614

gobject/gobject.c

index c22b655..d843d57 100644 (file)
@@ -543,7 +543,7 @@ g_object_class_install_property (GObjectClass *class,
     g_error ("Attempt to add property %s::%s to class after it was derived", G_OBJECT_CLASS_NAME (class), pspec->name);
 
   if (!g_type_is_in_init (G_OBJECT_CLASS_TYPE (class)))
-    g_critical ("Attempt to add property %s::%s after class was initialised", G_OBJECT_CLASS_NAME (class), pspec->name);
+    g_warning ("Attempt to add property %s::%s after class was initialised", G_OBJECT_CLASS_NAME (class), pspec->name);
 
   class->flags |= CLASS_HAS_PROPS_FLAG;
 
@@ -656,7 +656,7 @@ g_object_class_install_properties (GObjectClass  *oclass,
              G_OBJECT_CLASS_NAME (oclass));
 
   if (!g_type_is_in_init (G_OBJECT_CLASS_TYPE (oclass)))
-    g_critical ("Attempt to add properties %s after it was initialised", G_OBJECT_CLASS_NAME (oclass));
+    g_warning ("Attempt to add properties to %s after it was initialised", G_OBJECT_CLASS_NAME (oclass));
 
   oclass_type = G_OBJECT_CLASS_TYPE (oclass);
   parent_type = g_type_parent (oclass_type);