gobject: Warn if someone uses the wrong property in g_object_get/set
authorBenjamin Otte <otte@redhat.com>
Mon, 2 May 2011 17:22:25 +0000 (19:22 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 2 May 2011 17:33:51 +0000 (19:33 +0200)
"Interface::property" was not detected before and led to a crash.

gobject/gobject.c

index 7fa845f..ead9071 100644 (file)
@@ -1124,6 +1124,13 @@ object_get_property (GObject     *object,
   guint param_id = PARAM_SPEC_PARAM_ID (pspec);
   GParamSpec *redirect;
 
+  if (class == NULL)
+    {
+      g_warning ("'%s::%s' is not a valid property name; '%s' is not a GObject subtype",
+                 g_type_name (pspec->owner_type), pspec->name, g_type_name (pspec->owner_type));
+      return;
+    }
+
   redirect = g_param_spec_get_redirect_target (pspec);
   if (redirect)
     pspec = redirect;    
@@ -1143,6 +1150,13 @@ object_set_property (GObject             *object,
   GParamSpec *redirect;
   static gchar* enable_diagnostic = NULL;
 
+  if (class == NULL)
+    {
+      g_warning ("'%s::%s' is not a valid property name; '%s' is not a GObject subtype",
+                 g_type_name (pspec->owner_type), pspec->name, g_type_name (pspec->owner_type));
+      return;
+    }
+
   redirect = g_param_spec_get_redirect_target (pspec);
   if (redirect)
     pspec = redirect;