Check for duplicate property IDs as part of the property test

This commit is contained in:
Christian Dywan 2009-07-19 18:27:46 +02:00
parent e04ca23c2f
commit f4d19b68bf

View file

@ -58,6 +58,7 @@ properties_object_get_set (GObject* object)
GType type = G_PARAM_SPEC_TYPE (pspec); GType type = G_PARAM_SPEC_TYPE (pspec);
const gchar* property = g_param_spec_get_name (pspec); const gchar* property = g_param_spec_get_name (pspec);
void* value = NULL; void* value = NULL;
guint j;
/* Skip properties of parent classes */ /* Skip properties of parent classes */
if (pspec->owner_type != G_OBJECT_TYPE (object)) if (pspec->owner_type != G_OBJECT_TYPE (object))
@ -67,6 +68,16 @@ properties_object_get_set (GObject* object)
if (properties_should_skip (G_OBJECT_TYPE_NAME (object), property)) if (properties_should_skip (G_OBJECT_TYPE_NAME (object), property))
continue; continue;
/* Verify that the ID is unique */
if (pspecs[i]->owner_type == G_OBJECT_TYPE (object))
for (j = 0; j < n_properties; j++)
if (i != j && pspecs[j]->owner_type == G_OBJECT_TYPE (object))
if (pspec->param_id == pspecs[j]->param_id)
g_error ("Duplicate ID %d of %s and %s",
pspec->param_id,
g_param_spec_get_name (pspec),
g_param_spec_get_name (pspecs[j]));
g_object_get (object, property, &value, NULL); g_object_get (object, property, &value, NULL);
if (type == G_TYPE_PARAM_BOOLEAN) if (type == G_TYPE_PARAM_BOOLEAN)
{ {
@ -111,7 +122,6 @@ properties_object_get_set (GObject* object)
{ {
GEnumClass* enum_class = G_ENUM_CLASS ( GEnumClass* enum_class = G_ENUM_CLASS (
g_type_class_ref (pspec->value_type)); g_type_class_ref (pspec->value_type));
gint j;
if (pspec_is_writable (pspec)) if (pspec_is_writable (pspec))
{ {