padtemplate: Create pad templates with floating refs
authorSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 17 May 2011 10:10:27 +0000 (12:10 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Tue, 17 May 2011 11:13:51 +0000 (13:13 +0200)
And take ownership of the floating ref in gst_element_add_pad_template()

docs/random/porting-to-0.11.txt
gst/gstelement.c
gst/gstpadtemplate.c

index 0a3099e..eb8eeea 100644 (file)
@@ -98,6 +98,9 @@ The 0.11 porting guide
 
     gst_pad_template_new() does not take ownership of the caps anymore.
 
+    GstPadTemplate is now created with a floating ref and
+    gst_element_class_add_pad_template() takes ownership of this floating ref.
+
 * GstMiniObject
     A miniobject is now a simple refcounted structure holding the information
     common to buffers, events, messages, queries and caps.
index a047cf4..f8afa3d 100644 (file)
@@ -1297,6 +1297,9 @@ gst_element_class_add_pad_template (GstElementClass * klass,
     template_list = g_list_next (template_list);
   }
 
+  /* Take ownership of the floating ref */
+  g_object_ref_sink (templ);
+
   klass->padtemplates = g_list_append (klass->padtemplates, templ);
   klass->numpadtemplates++;
 }
index e5a57ff..e6c8c0b 100644 (file)
@@ -219,20 +219,6 @@ gst_pad_template_class_init (GstPadTemplateClass * klass)
 static void
 gst_pad_template_init (GstPadTemplate * templ)
 {
-  /* FIXME 0.11: Does anybody remember why this is here? If not, let's
-   * change it for 0.11 and let gst_element_class_add_pad_template() for
-   * example ref/sink the pad templates.
-   */
-  /* We ensure that the pad template we're creating has a sunken reference.
-   * Inconsistencies in pad templates being floating or sunken has caused
-   * problems in the past with leaks, etc.
-   *
-   * For consistency, then, we only produce them  with sunken references
-   * owned by the creator of the object
-   */
-  if (g_object_is_floating (templ)) {
-    gst_object_ref_sink (templ);
-  }
 }
 
 static void