From: Olivier CrĂȘte Date: Mon, 10 Apr 2017 16:24:06 +0000 (-0400) Subject: value: Accept NULL as a structure X-Git-Tag: 1.12.0~26 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dd1f0f49abfb35e38e7a2fa3a9229a384fbd0c9b;p=platform%2Fupstream%2Fgstreamer.git value: Accept NULL as a structure Some GstStructure properties default to NULL, so it should be a supported value. With unit test. --- diff --git a/gst/gstvalue.c b/gst/gstvalue.c index 5dcfd5ef45..5bf719798c 100644 --- a/gst/gstvalue.c +++ b/gst/gstvalue.c @@ -2754,6 +2754,12 @@ gst_value_compare_structure (const GValue * value1, const GValue * value2) GstStructure *structure1 = GST_STRUCTURE (g_value_get_boxed (value1)); GstStructure *structure2 = GST_STRUCTURE (g_value_get_boxed (value2)); + if (structure1 == structure2) + return GST_VALUE_EQUAL; + + if (!structure1 || !structure2) + return GST_VALUE_UNORDERED; + if (gst_structure_is_equal (structure1, structure2)) return GST_VALUE_EQUAL; diff --git a/tests/check/gst/gstvalue.c b/tests/check/gst/gstvalue.c index 9d3ae43bd6..639f175ee4 100644 --- a/tests/check/gst/gstvalue.c +++ b/tests/check/gst/gstvalue.c @@ -1048,6 +1048,23 @@ GST_START_TEST (test_value_compare) fail_unless (gst_value_compare (&value1, &value1) == GST_VALUE_EQUAL); g_value_unset (&value1); g_value_unset (&value2); + + /* Check that we can compare structure */ + { + GstStructure *s = gst_structure_new_empty ("test"); + + g_value_init (&value1, GST_TYPE_STRUCTURE); + g_value_init (&value2, GST_TYPE_STRUCTURE); + fail_unless (gst_value_compare (&value1, &value2) == GST_VALUE_EQUAL); + + gst_value_set_structure (&value1, s); + fail_unless (gst_value_compare (&value1, &value2) == GST_VALUE_UNORDERED); + gst_value_set_structure (&value2, s); + fail_unless (gst_value_compare (&value1, &value2) == GST_VALUE_EQUAL); + g_value_unset (&value1); + g_value_unset (&value2); + gst_structure_free (s); + } } GST_END_TEST;