summaryrefslogtreecommitdiff
authorAlessandro Decina <alessandro.decina@collabora.co.uk>2010-08-19 13:10:25 (GMT)
committer Alessandro Decina <alessandro.decina@collabora.co.uk>2010-08-20 08:31:38 (GMT)
commit00b4bfa48f23e671b40c36e428ebfc224f0e3c9c (patch) (side-by-side diff)
treead9efabb9f8e0f9d8e70f3bfcab921e68d5416c9
parentd246e0c592fa6222c2003c59b2dd1026b905933d (diff)
downloadgnonlin-00b4bfa48f23e671b40c36e428ebfc224f0e3c9c.zip
gnonlin-00b4bfa48f23e671b40c36e428ebfc224f0e3c9c.tar.gz
gnlcomposition: fail early in remove_object when removing an invalid object.
Make gnl_composition_remove_object return immediately FALSE when removing an object not contained in the composition.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--gnl/gnlcomposition.c15
-rw-r--r--tests/check/gnl/gnlcomposition.c20
2 files changed, 29 insertions, 6 deletions
diff --git a/gnl/gnlcomposition.c b/gnl/gnlcomposition.c
index 1c4e62d..fe16f6d 100644
--- a/gnl/gnlcomposition.c
+++ b/gnl/gnlcomposition.c
@@ -2609,6 +2609,12 @@ gnl_composition_remove_object (GstBin * bin, GstElement * element)
COMP_OBJECTS_LOCK (comp);
+ entry = COMP_ENTRY (comp, element);
+ if (entry == NULL) {
+ COMP_OBJECTS_UNLOCK (comp);
+ goto out;
+ }
+
gst_object_ref (element);
gst_element_set_locked_state (element, FALSE);
@@ -2629,8 +2635,7 @@ gnl_composition_remove_object (GstBin * bin, GstElement * element)
GST_LOG_OBJECT (element, "Removed from the objects start/stop list");
}
- if (!(g_hash_table_remove (comp->priv->objects_hash, element)))
- goto chiringuito;
+ g_hash_table_remove (comp->priv->objects_hash, element);
update_required = OBJECT_IN_ACTIVE_SEGMENT (comp, element) ||
(GNL_OBJECT_PRIORITY (element) == G_MAXUINT32) ||
@@ -2671,9 +2676,7 @@ beach:
}
gst_object_unref (element);
- return ret;
-chiringuito:
- COMP_OBJECTS_UNLOCK (comp);
- goto beach;
+out:
+ return ret;
}
diff --git a/tests/check/gnl/gnlcomposition.c b/tests/check/gnl/gnlcomposition.c
index dcb4f1a..9063a1c 100644
--- a/tests/check/gnl/gnlcomposition.c
+++ b/tests/check/gnl/gnlcomposition.c
@@ -214,6 +214,25 @@ GST_START_TEST (test_change_object_start_stop_in_current_stack)
GST_END_TEST;
+GST_START_TEST (test_remove_invalid_object)
+{
+ GstBin *composition;
+ GstElement *source1, *source2;
+
+ composition = GST_BIN (gst_element_factory_make ("gnlcomposition",
+ "composition"));
+ source1 = gst_element_factory_make ("gnlsource", "source1");
+ source2 = gst_element_factory_make ("gnlsource", "source2");
+
+ gst_bin_add (composition, source1);
+ fail_if (gst_bin_remove (composition, source2));
+ fail_unless (gst_bin_remove (composition, source1));
+
+ gst_object_unref (composition);
+}
+
+GST_END_TEST;
+
Suite *
gnonlin_suite (void)
{
@@ -223,6 +242,7 @@ gnonlin_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_change_object_start_stop_in_current_stack);
+ tcase_add_test (tc_chain, test_remove_invalid_object);
return s;
}