Project

General

Profile

Feature #1118

Clicking on the "File path" column of the playlist does not sort as expected.

Added by Gregor B 2 months ago. Updated 28 days ago.

Status:
New
Priority:
Minor
Assignee:
-
Category:
libaudcore
Start date:
July 25, 2021
Due date:
% Done:

0%

Estimated time:
Affects version:

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 about 2 months 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 about 2 months ago

  • Tracker changed from Bug to Support

#3 Updated by Gregor B about 2 months 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 28 days ago

  • Tracker changed from Support to Feature

Also available in: Atom PDF