After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 750585 - gst-play: sort directory entries
gst-play: sort directory entries
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal enhancement
: 1.5.2
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2015-06-08 17:35 UTC by Vivia Nikolaidou
Modified: 2015-06-08 19:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch filename (1.78 KB, patch)
2015-06-08 17:35 UTC, Vivia Nikolaidou
none Details | Review
Patch file (1.82 KB, patch)
2015-06-08 17:59 UTC, Vivia Nikolaidou
committed Details | Review

Description Vivia Nikolaidou 2015-06-08 17:35:06 UTC
Created attachment 304798 [details] [review]
Patch filename

When adding a directory to the playlist, the order would be whatever
g_dir_read_name returned. Sorting these using natural sort order.
Comment 1 Tim-Philipp Müller 2015-06-08 17:50:31 UTC
Comment on attachment 304798 [details] [review]
Patch filename

Thanks for the patch!

>       path = g_strconcat (filename, G_DIR_SEPARATOR_S, entry, NULL);
>-      add_to_playlist (playlist, path);
>+      files = g_list_append (files, g_strdup (path));
>       g_free (path);
>     }

Just use the newly-allocated path directly and remove the g_strdup() and g_free().
Also use g_list_prepend(), it's faster and we're going to sort it later anyway.
 
>+    files = g_list_sort (files, compare);
>+
>+    for (idx = files; idx; idx = g_list_next (idx)) {
>+      gchar *path = (gchar *) idx->data;
>+      add_to_playlist (playlist, path);
>+    }
>+    g_list_free (files);

I think this leaks the path string in idx->data ?
Comment 2 Tim-Philipp Müller 2015-06-08 17:52:20 UTC
Or use g_list_insert_sorted() from the start.
Comment 3 Vivia Nikolaidou 2015-06-08 17:59:33 UTC
Created attachment 304801 [details] [review]
Patch file
Comment 4 Tim-Philipp Müller 2015-06-08 19:27:15 UTC
Thanks, pushed with minor change (idx -> l which is more idiomatic).

commit 4fdbe215dcd55004ec00d42e875210b58bc0d2b6
Author: Vivia Nikolaidou <vivia@ahiru.eu>
Date:   Mon Jun 8 20:32:02 2015 +0300

    tools: gst-play: sort directory entries
    
    When adding a directory to the playlist, the order would be whatever
    g_dir_read_name returned. Sorting these using natural sort order.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=750585