Report only the most specific instantiatable prerequisite, filter out all
authorMatthias Clasen <matthiasc@src.gnome.org>
Sat, 19 Oct 2002 23:59:51 +0000 (23:59 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sat, 19 Oct 2002 23:59:51 +0000 (23:59 +0000)
* gtype.c (g_type_interface_prerequisites): Report only the most
specific instantiatable prerequisite, filter out all supertypes of
this one (the supertypes are added to the prerequisites array for
technical reasons).

gobject/gtype.c

index f9d0edd..7a302da 100644 (file)
@@ -1241,20 +1241,30 @@ g_type_interface_prerequisites (GType  interface_type,
   iface = lookup_type_node_I (interface_type);
   if (iface)
     {
-      GType *prerequisites;
-      guint i;
+      GType *types;
+      TypeNode *inode = NULL;
+      guint i, n = 0;
       
       G_READ_LOCK (&type_rw_lock);
-      prerequisites = g_new (GType, IFACE_NODE_N_PREREQUISITES (iface) + 1);
+      types = g_new0 (GType, IFACE_NODE_N_PREREQUISITES (iface) + 1);
       for (i = 0; i < IFACE_NODE_N_PREREQUISITES (iface); i++)
-       prerequisites[i] = IFACE_NODE_PREREQUISITES (iface)[i];
-      prerequisites[i] = 0;
+       {
+         GType prerequisite = IFACE_NODE_PREREQUISITES (iface)[i];
+         TypeNode *node = lookup_type_node_I (prerequisite);
+         if (node->is_instantiatable &&
+             (!inode || type_node_is_a_L (node, inode)))
+           inode = node;
+         else
+           types[n++] = NODE_TYPE (node);
+       }
+      if (inode)
+       types[n++] = NODE_TYPE (inode);
       
       if (n_prerequisites)
-       *n_prerequisites = IFACE_NODE_N_PREREQUISITES (iface);
+       *n_prerequisites = n;
       G_READ_UNLOCK (&type_rw_lock);
       
-      return prerequisites;
+      return types;
     }
   else
     {