GNOME Bugzilla – Bug 750585
gst-play: sort directory entries
Last modified: 2015-06-08 19:27:40 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 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 ?
Or use g_list_insert_sorted() from the start.
Created attachment 304801 [details] [review] Patch file
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