Skip to content

Windows: fix pathFromURL and implement Reveal Source#257

Merged
tedwaine merged 2 commits into
AcademySoftwareFoundation:developfrom
bdeluca:pr/fix-pathfromurl-windows
May 27, 2026
Merged

Windows: fix pathFromURL and implement Reveal Source#257
tedwaine merged 2 commits into
AcademySoftwareFoundation:developfrom
bdeluca:pr/fix-pathfromurl-windows

Conversation

@bdeluca
Copy link
Copy Markdown
Contributor

@bdeluca bdeluca commented May 27, 2026

Summary

helpers.pathFromURL on Windows returned url.toString() — the full file URL string with scheme, authority and URL-encoded reserved characters. That string flowed unchanged through every QML caller to user-visible text (window title, clipboard, dialog text fields) and to external process arguments (ffmpeg), producing artefacts like file:///Z:/path/foo.xst in the window title and ffmpeg output filenames such as file:///Z:/foo.%23%23%23%23.%04d.jpg.

Commit 1 replaces the pathFromURL Windows branch with a delegation to QUrl::toLocalFile() after patching the one URL shape Qt can't handle on its own (xstudio constructs URLs as file://localhost//<drive>:/..., which toLocalFile() interprets as a UNC \\localhost\<drive>:\... path; the Windows branch strips the localhost authority and collapses the doubled leading slash before delegating). It also implements the previously-empty Windows branch of showURIS using explorer.exe /select.

Commit 2 adds an explicit branch in VideoRendererDialog.choose_output for the case where the user types a filename that already contains ####. This case was previously masked because Qt URL-encoded the # characters and the with_hashes regex couldn't detect them; once pathFromURL returns a decoded path, the gap surfaces as the audio output filename no longer auto-filling.

Linux / macOS impact

None. The pathFromURL non-Windows branch (return url.path().replace("//", "/")) is untouched.

bdeluca added 2 commits May 27, 2026 15:10
pathFromURL on Windows returned url.toString() - the full file URL
string with scheme, authority and URL-encoded reserved characters.
That string then flowed unchanged through every QML caller to
user-visible text (window title, clipboard, dialog text fields) and
to external process arguments (ffmpeg), producing artefacts like
"file:///Z:/path/foo.xst" in the window title and ffmpeg output
filenames such as "file:///Z:/foo.%23%23%23%23.%04d.jpg".

Replace the pathFromURL Windows branch with a delegation to
QUrl::toLocalFile() after patching the one URL shape Qt can't handle
on its own: xstudio constructs URLs as file://localhost//<drive>:/...,
which toLocalFile() interprets as a UNC \\localhost\<drive>:\... path.
Strip the localhost authority and collapse the doubled leading slash;
Qt's conversion then yields a clean drive-letter path. Standard file
URLs and real UNC URLs are handled by toLocalFile() unchanged.

Implement the previously-empty Windows branch of showURIS using
explorer.exe /select,<native-path>, calling pathFromURL to obtain the
clean drive-letter path. explorer.exe /select takes a single target
per invocation (unlike macOS open -R and Linux ShowItems, which
accept a list), so the Windows branch reveals only the first URL in
the input.

The pathFromURL non-Windows branch (`return url.path().replace("//",
"/")`) is unchanged; Linux and macOS behaviour is preserved.

Signed-off-by: Ben de Luca <bdeluca@gmail.com>
choose_output had three intended branches over the regex matches:

  - filename contains a numeric frame range (foo.0001.jpg): replace
    digits with #### and set audio output to <prefix>.aiff
  - filename has neither a frame number nor hashes (foo.jpg): inject
    #### and set audio output to <prefix>.aiff
  - filename already contains hashes (foo.####.jpg): no branch

The third case had no handler. Previously this was masked because Qt
URL-encoded the # characters to %23 when serializing the file dialog
URL, and the with_hashes regex matched the literal # character only.
The encoded form failed the regex, the third branch was indistin-
guishable from the second, and audio output auto-filled by accident
via the !with_hashes branch.

With the previous commit applying QUrl::toLocalFile() in pathFromURL
the path is fully decoded before the regex runs, with_hashes
correctly matches the literal ####, and the missing case surfaces as
audio output not auto-filling when the user types ####. Add the
explicit `else if (with_hashes)` branch: keep the path as the user
wrote it and set the audio filename via the same ext[1] + "aiff"
prefix used by the other two branches.

Signed-off-by: Ben de Luca <bdeluca@gmail.com>
@bdeluca bdeluca force-pushed the pr/fix-pathfromurl-windows branch from 8bf55d6 to 359bce6 Compare May 27, 2026 12:11
@tedwaine tedwaine merged commit 2bd9ef1 into AcademySoftwareFoundation:develop May 27, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants