+2008-02-04 Thijs Vermeir <thijsvermeir@gmail.com>
+
+ * gst/gstpad.c:
+ * tests/check/gst/gstpad.c:
+ Be sure that we have a new copy of the caps and not
+ reffed caps from a template
+
2008-02-03 Sebastian Dröge <slomo@circular-chaos.org>
* gst/gstbin.c: (gst_bin_get_type), (gst_bin_class_init):
GST_CAT_DEBUG_OBJECT (GST_CAT_CAPS, pad, "get pad caps");
result = gst_pad_get_caps_unlocked (pad);
+
+ /* be sure that we have a copy */
+ if (result)
+ result = gst_caps_make_writable (result);
+
GST_OBJECT_UNLOCK (pad);
return result;
GST_END_TEST;
+/* gst_pad_get_caps should return a copy of the caps */
+GST_START_TEST (test_get_caps_must_be_copy)
+{
+ GstPad *pad;
+ GstCaps *caps;
+ GstPadTemplate *templ;
+
+ caps = gst_caps_new_any ();
+ templ =
+ gst_pad_template_new ("test_templ", GST_PAD_SRC, GST_PAD_ALWAYS, caps);
+ pad = gst_pad_new_from_template (templ, NULL);
+ fail_unless (GST_PAD_CAPS (pad) == NULL, "caps present on pad");
+ caps = gst_pad_get_caps (pad);
+
+ /* we must own the caps */
+ ASSERT_OBJECT_REFCOUNT (caps, "caps", 1);
+
+ /* cleanup */
+ gst_caps_unref (caps);
+ gst_object_unref (pad);
+ gst_object_unref (templ);
+}
+
+GST_END_TEST;
+
Suite *
gst_pad_suite (void)
{
tcase_add_test (tc_chain, test_push_negotiation);
tcase_add_test (tc_chain, test_src_unref_unlink);
tcase_add_test (tc_chain, test_sink_unref_unlink);
+ tcase_add_test (tc_chain, test_get_caps_must_be_copy);
return s;
}