From 789eda5a37bd63a7a192b694af1c8824720be949 Mon Sep 17 00:00:00 2001 From: Olivier CrĂȘte Date: Fri, 1 Nov 2013 16:35:59 +0000 Subject: parse: Make the FATAL_ERRORS flag also work without a GError Also add a unit tests --- gst/gstparse.c | 9 +++++++-- tests/check/pipelines/parse-launch.c | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/gst/gstparse.c b/gst/gstparse.c index a23cafa5e..75c6aa5c4 100644 --- a/gst/gstparse.c +++ b/gst/gstparse.c @@ -314,6 +314,7 @@ gst_parse_launch_full (const gchar * pipeline_description, { #ifndef GST_DISABLE_PARSE GstElement *element; + GError *myerror = NULL; g_return_val_if_fail (pipeline_description != NULL, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); @@ -321,16 +322,20 @@ gst_parse_launch_full (const gchar * pipeline_description, GST_CAT_INFO (GST_CAT_PIPELINE, "parsing pipeline description '%s'", pipeline_description); - element = priv_gst_parse_launch (pipeline_description, error, context, flags); + element = priv_gst_parse_launch (pipeline_description, &myerror, context, + flags); /* don't return partially constructed pipeline if FATAL_ERRORS was given */ - if (G_UNLIKELY (error != NULL && *error != NULL && element != NULL)) { + if (G_UNLIKELY (myerror != NULL && element != NULL)) { if ((flags & GST_PARSE_FLAG_FATAL_ERRORS)) { gst_object_unref (element); element = NULL; } } + if (myerror) + g_propagate_error (error, myerror); + return element; #else gchar *msg; diff --git a/tests/check/pipelines/parse-launch.c b/tests/check/pipelines/parse-launch.c index 8db1d6b50..fe292dfcb 100644 --- a/tests/check/pipelines/parse-launch.c +++ b/tests/check/pipelines/parse-launch.c @@ -651,6 +651,11 @@ GST_START_TEST (test_flags) fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS"); g_error_free (err); err = NULL; + + /* test GST_PARSE_FLAG_FATAL_ERRORS without GError */ + element = gst_parse_launch_full ("fakesrc ! coffeesink", NULL, + GST_PARSE_FLAG_FATAL_ERRORS, NULL); + fail_unless (element == NULL, "expected NULL return with FATAL_ERRORS"); } GST_END_TEST; -- cgit v1.2.3