mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 20:51:13 +00:00
harness: Handle element not being set cleanly.
If a harness is created with gst_harness_new_empty(), there might not be an internal element to unref on cleanup. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/686>
This commit is contained in:
parent
2a9267f2d4
commit
f6ce1686f1
2 changed files with 14 additions and 3 deletions
|
@ -1134,7 +1134,7 @@ gst_harness_teardown (GstHarness * h)
|
|||
priv->propose_allocation_metas = NULL;
|
||||
|
||||
/* if we hold the last ref, set to NULL */
|
||||
if (gst_harness_element_unref (h) == 0) {
|
||||
if (h->element != NULL && gst_harness_element_unref (h) == 0) {
|
||||
gboolean state_change;
|
||||
GstState state, pending;
|
||||
state_change = gst_element_set_state (h->element, GST_STATE_NULL);
|
||||
|
@ -1162,8 +1162,10 @@ gst_harness_teardown (GstHarness * h)
|
|||
g_ptr_array_unref (priv->stress);
|
||||
priv->stress = NULL;
|
||||
|
||||
if (h->element) {
|
||||
gst_object_unref (h->element);
|
||||
h->element = NULL;
|
||||
}
|
||||
|
||||
gst_object_replace ((GstObject **) & priv->testclock, NULL);
|
||||
|
||||
|
|
|
@ -25,6 +25,14 @@
|
|||
#include <gst/check/gstcheck.h>
|
||||
#include <gst/check/gstharness.h>
|
||||
|
||||
GST_START_TEST (test_harness_empty)
|
||||
{
|
||||
GstHarness *h = gst_harness_new_empty ();
|
||||
gst_harness_teardown (h);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static void
|
||||
create_destroy_element_harness (gpointer data, gpointer user_data)
|
||||
{
|
||||
|
@ -293,6 +301,7 @@ gst_harness_suite (void)
|
|||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
|
||||
tcase_add_test (tc_chain, test_harness_empty);
|
||||
tcase_add_test (tc_chain, test_harness_element_ref);
|
||||
tcase_add_test (tc_chain, test_src_harness);
|
||||
tcase_add_test (tc_chain, test_src_harness_no_forwarding);
|
||||
|
|
Loading…
Reference in a new issue