Skip to content

Append default suffix when saving/exporting with a single filter#139

Open
denisfalqueto wants to merge 1 commit into
musescore:mainfrom
denisfalqueto:fix/save-dialog-default-suffix
Open

Append default suffix when saving/exporting with a single filter#139
denisfalqueto wants to merge 1 commit into
musescore:mainfrom
denisfalqueto:fix/save-dialog-default-suffix

Conversation

@denisfalqueto

Copy link
Copy Markdown

Summary

On some Linux desktop environments, the native/portal file dialog used for
saving and exporting doesn't auto-append the file extension when the user
doesn't type one. This leaves the caller (e.g. PDF export in the main
MuseScore repo) unable to pick the correct writer for the returned path,
causing exports to silently fail.

  • In makeSelectFileQuery() (interactive.cpp), when opening a SaveFile
    dialog, request a defaultSuffix from the dialog derived from the
    suggested current path's own suffix.
  • This is only done when the caller offers a single filter. Some
    callers (e.g. "Save As" for a MuseScore project) offer two filters at
    once — the normal *.mscz format and an experimental uncompressed-folder
    option — and a dialog-wide default suffix would be applied regardless of
    which filter the user actually selected, silently defeating the
    alternate option. That ambiguous case is left untouched.

Companion PR

This is a companion fix to a related PR in musescore/MuseScore
(src/app/main.cpp and src/project/internal/exportprojectscenario.cpp),
which adds a safety net that enforces the correct suffix after the dialog
returns, regardless of dialog backend.

Testing

Verified with a full local Debug build of MuseScore Studio (main repo,
pointing at this branch) on KDE Plasma Wayland:

  • Exporting to PDF without typing an extension now correctly produces a
    .pdf file.
  • Exporting to PDF while typing .pdf explicitly still works, without a
    duplicated suffix.
  • Keyboard interaction inside the file dialog (arrow keys, typing, Enter to
    confirm) verified unaffected — this was a deliberate regression check,
    since a past issue (#13113) was caused by a different, broken Linux file
    dialog swallowing keyboard input.

Disclaimer

This change was implemented with the assistance of Claude Code (Anthropic),
which performed the code changes, the build, and the testing steps
described above. A human reviewed and validated the entire process step by
step, and endorses the final result.

…le filter

Some Linux native/portal file dialogs don't auto-append the file extension
when the user doesn't type one. When the caller offers a single filter
(e.g. exporting to PDF), request a defaultSuffix from the dialog so the
returned path always has the expected extension. This is skipped when more
than one filter is offered (e.g. "Save As" with the experimental
uncompressed-folder option), since a single global default suffix would be
applied regardless of which filter the user actually picked.

Resolves: musescore/MuseScore#33559
Resolves: musescore/MuseScore#33341
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5c973470-c42e-48b5-975c-ec448bc4e084

📥 Commits

Reviewing files that changed from the base of the PR and between 0d10cd3 and 7ef638f.

📒 Files selected for processing (1)
  • framework/interactive/internal/interactive.cpp

📝 Walkthrough

Walkthrough

This change modifies the Linux implementation of the internal makeSelectFileQuery function used in the save-file flow. When exactly one filename filter is provided and the current path has a non-empty file suffix, that suffix is extracted and set as the query's defaultSuffix. The change is scoped to the SaveFile branch under the Linux platform condition, with no other modes or branches affected, and no public or exported declarations altered.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the change, motivation, testing, and companion PR, but it omits the required issue reference and checklist completion. Add the required Resolves issue line and complete the checklist items in the repository template.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: adding a default suffix for Linux save/export dialogs with a single filter.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

denisfalqueto added a commit to denisfalqueto/MuseScore that referenced this pull request Jul 9, 2026
…ainst file dialog quirks

Two independent fixes for PDF export failing/crashing on Linux:

- src/app/main.cpp: only force QT_QPA_PLATFORMTHEME=gtk3 when the user
  hasn't already set it. gtk3 was forced unconditionally to fix keyboard
  input in the legacy Qt file dialog (musescore#13113), but this also silently
  overrode any theme the user configured (e.g. "xdgdesktopportal" for
  proper portal/sandboxed dialog support), which is a likely contributor
  to file dialogs not respecting the user's desktop environment. The
  default (gtk3) is unchanged for users who don't set this variable, so
  musescore#13113 is not reintroduced. QT_QPA_PLATFORM=xcb is left untouched, since
  it fixes unrelated Wayland issues (VST crashes musescore#28446, panel docking
  musescore#28352).

- src/project/internal/exportprojectscenario.cpp: after the file dialog
  returns a save path, force the expected export suffix if the path
  doesn't already have one of the format's known suffixes. On some Linux
  native/portal dialogs the extension isn't auto-appended when the user
  doesn't type one, which previously left exportScores() unable to find a
  writer for the path, causing the export to silently fail.

A companion fix in muse_framework (musescore/muse_framework#139) makes the
underlying file dialog request a default suffix directly, which addresses
the same root cause at the source for the single-format case; this commit
adds a safety net that's independent of dialog backend.

Resolves: musescore#33341
Resolves: musescore#33559
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.

1 participant