Feature #1118
Clicking on the "File path" column of the playlist does not sort as expected.
0%
Description
Bug description: I noticed that clicking the "File path" column of the playlist shuffles around playlist items, even if all paths are the same.
Initially I thought the error might be that the sort algorithm is not stable, but it turned out it actually is (since Glib 2.32). The problem is with the actual path comparison function in playlist-utils.cc:
// line 40ff
static int filename_compare_path(const char * a, const char * b)
{
[...]
// in all other cases, compare the entire paths
return str_compare_encoded(a, b);
}
There is some trickery that handles subdirectories, but in the default case (shown in this snippet), a and b are compared, which is the full file path, not just the dir name as shown in the column. To get it "working on my machine" I create a temporary string that is terminated at the end of the dirname and compare against that, which works as expected:
static int filename_compare_path(const char * a, const char * b)
{
const long maximum_pathlen = 4096;
char path_a[maximum_pathlen];
{
int length = std::min(get_basename(a) - a, maximum_pathlen - 1);
memcpy(path_a, a, length);
path_a[length] = 0;
}
char path_b[maximum_pathlen];
{
int length = std::min(get_basename(b) - b, maximum_pathlen - 1);
memcpy(path_b, b, length);
path_b[length] = 0;
}
return str_compare_encoded(path_a, path_b);
}
But this is just a quickfix without getting too deep of an understanding of the interals of Audacity, so ymmv / it may break other things I do not use.
Best regards
Gregor
History
#1 Updated by John Lindgren over 3 years ago
It is working as designed. Maybe the meaning of "File path" should be clarified though. "File path" in this case includes the file name.
#2 Updated by John Lindgren over 3 years ago
- Tracker changed from Bug to Support
#3 Updated by Gregor B over 3 years ago
John Lindgren wrote:
It is working as designed. Maybe the meaning of "File path" should be clarified though. "File path" in this case includes the file name.
Maybe that is the case. But from a user experience perspective without prior knowledge about how the internals work, I would expect that clicking on a column in Audacity sorts after what is displayed in the column, which is not the full path including file, but just the directory.
In any case maybe "feature request" would be more appropriate than "support" then.
#4 Updated by John Lindgren about 3 years ago
- Tracker changed from Support to Feature
#5 Updated by Gregor B almost 2 years ago
For consideration: This makes sorting by [anything] first and by path as a fallback impossible, because the path including filename is unique. Let's say the path includes the interpreter's and album name, then you may want to sort your playlist by track id, from the metadata, first and then by path.
Which does not work at all, as sorting by the file name will destroy any previous ordering.