Skip to content

Robustify Linux PDF export against file dialog quirks - #34127

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

Robustify Linux PDF export against file dialog quirks#34127
denisfalqueto wants to merge 3 commits 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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR contains two independent fixes. On Linux, QT_QPA_PLATFORMTHEME is set to gtk3 only when MU_QT_QPA_PLATFORM is not offscreen and the variable is not already set. askExportPath() validates the selected path suffix and appends the first suffix from exportType.suffixes when the suffix is missing or unknown.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the primary Linux PDF export and file-dialog fixes.
Description check ✅ Passed The description explains the causes, fixes, linked issues, testing, and scope; the template checklist is omitted.
Linked Issues check ✅ Passed The changes address Linux export failures and PDF creation [#33341, #33559] while preserving file-dialog keyboard behavior [#13113].
Out of Scope Changes check ✅ Passed All changes support the linked Linux file-dialog and export objectives, with no unrelated code changes identified.
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.


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
@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.

@denisfalqueto
denisfalqueto force-pushed the fix/linux-pdf-export-dialog branch 2 times, most recently from 41a50ba to 02f33cb Compare July 27, 2026 10:44
@denisfalqueto
denisfalqueto force-pushed the fix/linux-pdf-export-dialog branch from 02f33cb to f23d35d Compare August 10, 2026 09:54
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@denisfalqueto
denisfalqueto force-pushed the fix/linux-pdf-export-dialog branch 2 times, most recently from 077f8c3 to e7af032 Compare August 15, 2026 12:44
…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 660b487 to 6d98db0 Compare August 20, 2026 02:46
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

3 participants