parse: Make the FATAL_ERRORS flag also work without a GError
authorOlivier Crête <olivier.crete@collabora.com>
Fri, 1 Nov 2013 16:35:59 +0000 (16:35 +0000)
committerOlivier Crête <olivier.crete@collabora.com>
Fri, 1 Nov 2013 17:02:25 +0000 (17:02 +0000)
Also add a unit tests

gst/gstparse.c
tests/check/pipelines/parse-launch.c

index a23cafa..75c6aa5 100644 (file)
@@ -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;
index 8db1d6b..fe292df 100644 (file)
@@ -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;