index: fix creation of writer id for unparented pads
authorStefan Kost <ensonic@users.sf.net>
Thu, 17 Feb 2011 12:50:40 +0000 (14:50 +0200)
committerStefan Kost <ensonic@users.sf.net>
Thu, 17 Feb 2011 12:54:05 +0000 (14:54 +0200)
Also do some cleanup in the impl.

gst/gstindex.c

index b686eeebfa2488ec10a8946bead6998decd9b658..5f4b2fbd72eeb7e75254717a427673ff98a26895 100644 (file)
@@ -633,20 +633,23 @@ gst_index_gtype_resolver (GstIndex * index, GstObject * writer,
   g_return_val_if_fail (writer != NULL, FALSE);
 
   if (GST_IS_PAD (writer)) {
-    GstElement *element =
-        (GstElement *) gst_object_get_parent (GST_OBJECT (writer));
+    GstObject *element = gst_object_get_parent (GST_OBJECT (writer));
     gchar *name;
 
     name = gst_object_get_name (writer);
-    *writer_string = g_strdup_printf ("%s.%s",
-        g_type_name (G_OBJECT_TYPE (element)), name);
+    if (element) {
+      *writer_string = g_strdup_printf ("%s.%s",
+          G_OBJECT_TYPE_NAME (element), name);
+      gst_object_unref (element);
+    } else {
+      *writer_string = name;
+      name = NULL;
+    }
 
-    gst_object_unref (element);
     g_free (name);
 
   } else {
-    *writer_string =
-        g_strdup_printf ("%s", g_type_name (G_OBJECT_TYPE (writer)));
+    *writer_string = g_strdup (G_OBJECT_TYPE_NAME (writer));
   }
 
   return TRUE;