From 52f7150de4934136441b95791b92e843467acc31 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Sat, 22 Jan 2022 02:24:23 +0100 Subject: [PATCH] ges: preserve discovery order The previous code was storing container children in reverse addition order, this was mitigated by the fact that track elements were also stored in reverse order, thus restoring the original order, but it seems more consistent to preserve order throughout, the extra cost of append operations is negligible. Part-of: --- .../gst-editing-services/ges/ges-clip.c | 2 +- .../gst-editing-services/ges/ges-container.c | 2 +- .../gst-editing-services/ges/ges-uri-clip.c | 2 +- .../tests/check/ges/clip.c | 26 +++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/subprojects/gst-editing-services/ges/ges-clip.c b/subprojects/gst-editing-services/ges/ges-clip.c index 1b297b37a5..3640f43cea 100644 --- a/subprojects/gst-editing-services/ges/ges-clip.c +++ b/subprojects/gst-editing-services/ges/ges-clip.c @@ -2008,7 +2008,7 @@ _child_removed (GESContainer * container, GESTimelineElement * element) static void add_clip_to_list (gpointer key, gpointer clip, GList ** list) { - *list = g_list_prepend (*list, gst_object_ref (clip)); + *list = g_list_append (*list, gst_object_ref (clip)); } /* NOTE: Since this does not change the track of @child, this should diff --git a/subprojects/gst-editing-services/ges/ges-container.c b/subprojects/gst-editing-services/ges/ges-container.c index 71c3f3801f..52c1463433 100644 --- a/subprojects/gst-editing-services/ges/ges-container.c +++ b/subprojects/gst-editing-services/ges/ges-container.c @@ -761,7 +761,7 @@ ges_container_add (GESContainer * container, GESTimelineElement * child) mapping = g_slice_new0 (ChildMapping); mapping->child = gst_object_ref (child); g_hash_table_insert (priv->mappings, child, mapping); - container->children = g_list_prepend (container->children, child); + container->children = g_list_append (container->children, child); /* Listen to all property changes */ mapping->start_notifyid = diff --git a/subprojects/gst-editing-services/ges/ges-uri-clip.c b/subprojects/gst-editing-services/ges/ges-uri-clip.c index fccd3841b4..64082cdbe0 100644 --- a/subprojects/gst-editing-services/ges/ges-uri-clip.c +++ b/subprojects/gst-editing-services/ges/ges-uri-clip.c @@ -583,7 +583,7 @@ ges_uri_clip_create_track_elements (GESClip * clip, GESTrackType type) NULL)); ges_timeline_element_set_max_duration (GES_TIMELINE_ELEMENT (element), max_duration); - res = g_list_prepend (res, element); + res = g_list_append (res, element); } } diff --git a/subprojects/gst-editing-services/tests/check/ges/clip.c b/subprojects/gst-editing-services/tests/check/ges/clip.c index f2a9d23dc2..b9d9eefe3c 100644 --- a/subprojects/gst-editing-services/tests/check/ges/clip.c +++ b/subprojects/gst-editing-services/tests/check/ges/clip.c @@ -614,12 +614,15 @@ GST_START_TEST (test_split_object) /* core elements have swapped order in the clip, this is ok since they * share the same priority */ - assert_equal_children_properties (splittrackelement, trackelement2); - fail_unless (ges_track_element_get_track (splittrackelement) == track2); - fail_unless (ges_track_element_get_track (trackelement2) == track2); + assert_equal_children_properties (splittrackelement, trackelement1); + fail_unless (ges_track_element_get_track (splittrackelement) == track1); + fail_unless (ges_track_element_get_track (trackelement1) == track1); assert_equals_int (GES_TIMELINE_ELEMENT_PRIORITY (splittrackelement), - priority2 + 3); - fail_unless (GES_TIMELINE_ELEMENT_PRIORITY (trackelement2) == priority2); + priority1 + 3); + fail_unless (GES_TIMELINE_ELEMENT_PRIORITY (trackelement1) == priority1); + meta = ges_meta_container_get_string (GES_META_CONTAINER (splittrackelement), + "test_key"); + fail_unless_equals_string (meta, "test_value"); fail_unless (splittrackelement != trackelement1); fail_unless (splittrackelement != trackelement2); @@ -631,15 +634,12 @@ GST_START_TEST (test_split_object) fail_unless (GES_IS_TRACK_ELEMENT (splittrackelement)); CHECK_OBJECT_PROPS (splittrackelement, 67, 37, 25); - assert_equal_children_properties (splittrackelement, trackelement1); - fail_unless (ges_track_element_get_track (splittrackelement) == track1); - fail_unless (ges_track_element_get_track (trackelement1) == track1); + assert_equal_children_properties (splittrackelement, trackelement2); + fail_unless (ges_track_element_get_track (splittrackelement) == track2); + fail_unless (ges_track_element_get_track (trackelement2) == track2); assert_equals_int (GES_TIMELINE_ELEMENT_PRIORITY (splittrackelement), - priority1 + 3); - fail_unless (GES_TIMELINE_ELEMENT_PRIORITY (trackelement1) == priority2); - meta = ges_meta_container_get_string (GES_META_CONTAINER (splittrackelement), - "test_key"); - fail_unless_equals_string (meta, "test_value"); + priority2 + 3); + fail_unless (GES_TIMELINE_ELEMENT_PRIORITY (trackelement2) == priority2); fail_unless (splittrackelement != trackelement1); fail_unless (splittrackelement != trackelement2);