gst/gstelementfactory.c: Unref the factory after it was used the last time, not before.
authorSebastian Dröge <slomo@circular-chaos.org>
Wed, 23 Apr 2008 14:54:20 +0000 (14:54 +0000)
committerSebastian Dröge <slomo@circular-chaos.org>
Wed, 23 Apr 2008 14:54:20 +0000 (14:54 +0000)
Original commit message from CVS:
* gst/gstelementfactory.c: (gst_element_factory_make):
Unref the factory after it was used the last time, not before.
* gst/gstindexfactory.c: (gst_index_factory_make):
Improve debugging a bit and don't leak a ref to the index factory with
each call.

ChangeLog
gst/gstelementfactory.c
gst/gstindexfactory.c

index 871ff33..5a72393 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-04-23  Sebastian Dröge  <slomo@circular-chaos.org>
+
+       * gst/gstelementfactory.c: (gst_element_factory_make):
+       Unref the factory after it was used the last time, not before.
+
+       * gst/gstindexfactory.c: (gst_index_factory_make):
+       Improve debugging a bit and don't leak a ref to the index factory with
+       each call.
+
 2008-04-23  Stefan Kost  <ensonic@users.sf.net>
 
        * gst/gstregistry.c:
index 02a3ce3..cf13165 100644 (file)
@@ -472,10 +472,10 @@ gst_element_factory_make (const gchar * factoryname, const gchar * name)
 
   GST_LOG_OBJECT (factory, "found factory %p", factory);
   element = gst_element_factory_create (factory, name);
-  gst_object_unref (factory);
   if (element == NULL)
     goto create_failed;
 
+  gst_object_unref (factory);
   return element;
 
   /* ERRORS */
@@ -487,6 +487,7 @@ no_factory:
 create_failed:
   {
     GST_INFO_OBJECT (factory, "couldn't create instance!");
+    gst_object_unref (factory);
     return NULL;
   }
 }
index ced0cbe..cf268a5 100644 (file)
@@ -205,13 +205,33 @@ GstIndex *
 gst_index_factory_make (const gchar * name)
 {
   GstIndexFactory *factory;
+  GstIndex *index;
 
   g_return_val_if_fail (name != NULL, NULL);
 
   factory = gst_index_factory_find (name);
 
   if (factory == NULL)
-    return NULL;
+    goto no_factory;
+
+  index = gst_index_factory_create (factory);
+
+  if (index == NULL)
+    goto create_failed;
+
+  gst_object_unref (factory);
+  return index;
 
-  return gst_index_factory_create (factory);
+  /* ERRORS */
+no_factory:
+  {
+    GST_INFO ("no such index factory \"%s\"!", name);
+    return NULL;
+  }
+create_failed:
+  {
+    GST_INFO_OBJECT (factory, "couldn't create instance!");
+    gst_object_unref (factory);
+    return NULL;
+  }
 }