Skip to content

Robustify Linux PDF export against file dialog quirks#34127

Open
denisfalqueto wants to merge 1 commit into
musescore:mainfrom
denisfalqueto:fix/linux-pdf-export-dialog
Open

Robustify Linux PDF export against file dialog quirks#34127
denisfalqueto wants to merge 1 commit into
musescore:mainfrom
denisfalqueto:fix/linux-pdf-export-dialog

Conversation

@denisfalqueto

Copy link
Copy Markdown

Summary

Fixes two related symptoms reported on Linux (Arch/Manjaro/Fedora/CachyOS,
mostly under KDE Plasma Wayland with Qt 6.11):

  • The file save/export dialog doesn't respect the desktop's xdg-desktop-portal
    configuration.
  • PDF export silently fails (no file created) or, in some environments,
    crashes — including when the file name is typed with the extension.

Resolves #33341, resolves #33559.

Root cause 1 — theme forced unconditionally

src/app/main.cpp unconditionally forces QT_QPA_PLATFORMTHEME=gtk3 on
Linux. This overrides any theme the user has explicitly configured (e.g.
xdgdesktopportal, for proper native/sandboxed dialog support via the
portal), which is a likely contributor to dialogs not respecting the
desktop environment and to instability in some Wayland setups.

Fix: only apply the gtk3 default when the user hasn't already set
QT_QPA_PLATFORMTHEME. The default is unchanged for everyone who doesn't
set it.

I want to flag why gtk3 is forced in the first place, for reviewers:
it was introduced in #13847 to fix #13113 ("keyboard doesn't work in file
dialogs"), where the legacy Qt widget dialog swallowed keyboard input.
This PR does not change that default, only whether it can be
overridden — so #13113 should not be reintroduced. I also intentionally
left QT_QPA_PLATFORM=xcb untouched; it was introduced in #28461 to fix
unrelated Wayland issues (VST crash #28446, panel docking #28352) and
removing it risks regressing those.

Root cause 2 — missing extension breaks writer lookup

On some Linux native/portal file dialogs, the extension isn't
auto-appended when the user doesn't type one. exportScores() in
src/project/internal/exportprojectscenario.cpp picks the writer by the
returned path's suffix (io::suffix()), so a missing suffix meant no
writer was found and the export silently failed.

Fix: after the dialog returns, force the expected suffix (from
exportType.suffixes) if the returned path doesn't already have one of
the known suffixes for that export format.

A companion PR in muse_framework
(musescore/muse_framework#139) makes the dialog itself request a
defaultSuffix for the single-format case, addressing the same root
cause closer to the source. This PR's fix is independent of the dialog
backend and acts as a safety net either way.

Note: I looked into also fixing the analogous "Save As" ambiguity for
.mscz vs. the experimental uncompressed-folder option
(src/project/internal/opensaveprojectscenario.cpp), but
selectSavingFileSync() doesn't currently report which of the two
filters the user selected, making a suffix-based heuristic there
genuinely ambiguous (forcing .mscz on empty suffix would break the
folder option for users who select it correctly). Left that out of scope
for this PR rather than risk a different regression.

Testing

Built locally (Debug) and manually tested on KDE Plasma Wayland, with the
companion muse_framework branch checked out:

  1. Export to PDF without typing an extension → now correctly produces
    name.pdf (previously failed/crashed).
  2. Export to PDF typing .pdf explicitly → still works, no duplicated
    suffix.
  3. Keyboard interaction inside the file dialog (arrow keys, typing text,
    Enter to confirm) → works normally, no regression of [MU4 Issue] keyboard doesn't work in file dialogs  #13113.
  4. App starts and runs without crashing.

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.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 859305fc-a698-4289-b1c2-b002fec6e316

📥 Commits

Reviewing files that changed from the base of the PR and between 0bbf8ab and dfcc9bf.

📒 Files selected for processing (2)
  • src/app/main.cpp
  • src/project/internal/exportprojectscenario.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/app/main.cpp
  • src/project/internal/exportprojectscenario.cpp

📝 Walkthrough

Walkthrough

This PR contains two independent fixes. In main.cpp, the logic that sets QT_QPA_PLATFORMTHEME to gtk3 now also checks whether that environment variable is already set, in addition to checking that the platform is not offscreen. In exportprojectscenario.cpp, askExportPath() now validates the selected export path suffix against known export suffixes and appends the first valid suffix when the current suffix is unrecognized.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately reflects the Linux file-dialog/export fixes, even if it omits the suffix fallback detail.
Description check ✅ Passed The description is detailed and mostly matches the template's intent, but it omits the checklist section.
Linked Issues check ✅ Passed The theme override and suffix fix address the Linux/AppImage export failures and preserve file-dialog keyboard behavior for [#33341, #33559, #13113].
Out of Scope Changes check ✅ Passed The changes stay within the export/file-dialog scope and do not introduce unrelated functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Review ran into problems

🔥 Problems

Linked repositories: Public OSS repositories can only analyze public repositories installed in this organization. No linked repositories were analyzed; skipped musescore/muse_framework.git.


Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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.

@RomanPudashkin RomanPudashkin requested a review from Eism July 8, 2026 13:57
…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
@denisfalqueto denisfalqueto force-pushed the fix/linux-pdf-export-dialog branch from 0bbf8ab to dfcc9bf Compare July 9, 2026 13:02
@denisfalqueto

Copy link
Copy Markdown
Author

I just did a rebase on branch master to get some fixes for my personal use.

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.

Exporting is broken PDF export is not working in 4.7.1 [MU4 Issue] keyboard doesn't work in file dialogs

2 participants