gst: Handle floating references consistently

If a function takes a floating reference parameter, it should also be
sinked in error cases. Otherwise the function behaves differently
between error and normal cases, which is impossible for bindings to
handle.

https://bugzilla.gnome.org/show_bug.cgi?id=747990
This commit is contained in:
Sebastian Dröge 2017-05-15 14:29:05 +03:00
parent 7c4d3a6c52
commit 2e4c82d850
5 changed files with 5 additions and 7 deletions

View file

@ -1367,6 +1367,8 @@ adding_itself:
GST_OBJECT_LOCK (bin);
g_warning ("Cannot add bin '%s' to itself", GST_ELEMENT_NAME (bin));
GST_OBJECT_UNLOCK (bin);
gst_object_ref_sink (element);
gst_object_unref (element);
return FALSE;
}
duplicate_name:
@ -1384,8 +1386,6 @@ had_parent:
g_warning ("Element '%s' already has parent", elem_name);
GST_OBJECT_UNLOCK (bin);
g_free (elem_name);
gst_object_ref_sink (element);
gst_object_unref (element);
return FALSE;
}
}

View file

@ -734,8 +734,6 @@ had_parent:
pad_name, GST_ELEMENT_NAME (element));
GST_OBJECT_UNLOCK (element);
g_free (pad_name);
gst_object_ref_sink (pad);
gst_object_unref (pad);
return FALSE;
}
no_direction:
@ -1275,6 +1273,7 @@ gst_element_class_add_pad_template (GstElementClass * klass,
/* Found pad with the same name, replace and return */
if (strcmp (templ->name_template, padtempl->name_template) == 0) {
gst_object_ref_sink (padtempl);
gst_object_unref (padtempl);
template_list->data = templ;
return;

View file

@ -615,7 +615,6 @@ parent_failed:
g_critical ("Could not set internal pad %s:%s",
GST_DEBUG_PAD_NAME (internal));
GST_OBJECT_UNLOCK (pad);
gst_object_unref (internal);
return FALSE;
}
}

View file

@ -444,6 +444,8 @@ gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
GST_WARNING_OBJECT (registry,
"Not replacing plugin because new one (%s) is blacklisted but for a different location than existing one (%s)",
plugin->filename, existing_plugin->filename);
/* Keep reference counting consistent */
gst_object_ref_sink (plugin);
gst_object_unref (plugin);
GST_OBJECT_UNLOCK (registry);
return FALSE;

View file

@ -1475,7 +1475,6 @@ ghost_up (GstElement * e, GstPad * pad)
if (!gst_element_add_pad ((GstElement *) parent, gpad)) {
g_warning ("Pad named %s already exists in element %s\n",
GST_OBJECT_NAME (gpad), GST_OBJECT_NAME (parent));
gst_object_unref ((GstObject *) gpad);
GST_STATE_UNLOCK (parent);
return NULL;
}
@ -2059,7 +2058,6 @@ gst_element_link_pads_filtered (GstElement * src, const gchar * srcpadname,
if (!gst_bin_add (GST_BIN (parent), capsfilter)) {
GST_ERROR ("Could not add capsfilter");
gst_object_unref (capsfilter);
gst_object_unref (parent);
return FALSE;
}