gst/gstpad.c: Use g_value_get_object() instead of g_value_dup_gst_object(), to avoid double-reffing the pad template ...

Original commit message from CVS:
* gst/gstpad.c: (gst_pad_set_property):
Use g_value_get_object() instead of g_value_dup_gst_object(),
to avoid double-reffing the pad template (which we then sink,
so this worked previously if (and only if) the pad template
was floating.

* gst/gstpadtemplate.c: (gst_pad_template_init),
(gst_pad_template_pad_created):
Never return floating references to pad templates, create
them as initially-sunken.

Document an extra function (and make this stop sinking our
pad template, since that is now guaranteed to do nothing,
since we created it sunken).

* gst/gstghostpad.c:
Fix docs typo.
This commit is contained in:
Michael Smith 2006-04-06 15:07:12 +00:00
parent a0d6437c15
commit 6c40c7595e
5 changed files with 44 additions and 6 deletions

View file

@ -1,3 +1,23 @@
2006-04-06 Michael Smith <msmith@fluendo.com>
* gst/gstpad.c: (gst_pad_set_property):
Use g_value_get_object() instead of g_value_dup_gst_object(),
to avoid double-reffing the pad template (which we then sink,
so this worked previously if (and only if) the pad template
was floating.
* gst/gstpadtemplate.c: (gst_pad_template_init),
(gst_pad_template_pad_created):
Never return floating references to pad templates, create
them as initially-sunken.
Document an extra function (and make this stop sinking our
pad template, since that is now guaranteed to do nothing,
since we created it sunken).
* gst/gstghostpad.c:
Fix docs typo.
2006-04-06 Tim-Philipp Müller <tim at centricular dot net>
* gst/gstinfo.c: (__gst_in_valgrind):

2
common

@ -1 +1 @@
Subproject commit 623fe1c2cce45bc30d5823c05716349874ae994e
Subproject commit 1783855e983a5294434673694e8a57e44980b6f1

View file

@ -36,7 +36,7 @@
* If the target pad is known at creation time, gst_ghost_pad_new() is the
* function to use to get a ghost-pad. Otherwise one can use gst_ghost_pad_new_no_target()
* to create the ghost-pad and use gst_ghost_pad_set_target() to establish the
* accociation later on.
* association later on.
*
* Last reviewed on 2005-11-18 (0.9.5)
*/

View file

@ -421,7 +421,7 @@ gst_pad_set_property (GObject * object, guint prop_id,
break;
case PAD_PROP_TEMPLATE:
gst_pad_set_pad_template (GST_PAD_CAST (object),
(GstPadTemplate *) g_value_dup_gst_object (value));
(GstPadTemplate *) g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View file

@ -119,7 +119,8 @@ static GstObject *parent_class = NULL;
static guint gst_pad_template_signals[LAST_SIGNAL] = { 0 };
static void gst_pad_template_class_init (GstPadTemplateClass * klass);
static void gst_pad_template_init (GstPadTemplate * templ);
static void gst_pad_template_init (GstPadTemplate * templ,
GstPadTemplateClass * klass);
static void gst_pad_template_dispose (GObject * object);
GType
@ -172,8 +173,19 @@ gst_pad_template_class_init (GstPadTemplateClass * klass)
}
static void
gst_pad_template_init (GstPadTemplate * templ)
gst_pad_template_init (GstPadTemplate * templ, GstPadTemplateClass * klass)
{
/* 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 (GST_OBJECT_IS_FLOATING (templ)) {
gst_object_ref (templ);
gst_object_sink (templ);
}
}
static void
@ -346,10 +358,16 @@ gst_pad_template_get_caps (GstPadTemplate * templ)
return GST_PAD_TEMPLATE_CAPS (templ);
}
/**
* gst_pad_template_pad_created:
* @templ: a #GstPadTemplate that has been created
* @pad: the #GstPad that created it
*
* Emit the pad-created signal for this template when created by this pad.
*/
void
gst_pad_template_pad_created (GstPadTemplate * templ, GstPad * pad)
{
gst_object_sink (GST_OBJECT (templ));
g_signal_emit (G_OBJECT (templ),
gst_pad_template_signals[TEMPL_PAD_CREATED], 0, pad);
}