Skip to content

Commit

Permalink
Check if given classname exists in GType system. Refs gh-120
Browse files Browse the repository at this point in the history
  • Loading branch information
piotras committed Sep 9, 2011
1 parent 4b66acc commit 6c70a2a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/midgard_schema_object_factory.c
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,14 @@ midgard_schema_object_factory_get_object_by_path (MidgardConnection *mgd, const
g_return_val_if_fail (classname != NULL, NULL);
g_return_val_if_fail (path != NULL, NULL);

GType class_type = g_type_from_name (classname);
if (class_type == G_TYPE_INVALID
|| !g_type_is_a (class_type, MIDGARD_TYPE_DBOBJECT)) {
g_warning ("Invalid '%s' classname. Expected MidgardDBObject derived one");
/* TODO, add error */
return NULL;
}

MIDGARD_ERRNO_SET(mgd, MGD_ERR_OK);

gchar *object_path = NULL;
Expand Down

0 comments on commit 6c70a2a

Please sign in to comment.