From 7ef638f6223195bf71aa6541ffde5d9fdf9bb36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20A=2E=20Alto=C3=A9=20Falqueto?= Date: Wed, 8 Jul 2026 10:40:23 -0300 Subject: [PATCH] Fixed #33559: append default suffix when saving/exporting with a single 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 --- framework/interactive/internal/interactive.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/framework/interactive/internal/interactive.cpp b/framework/interactive/internal/interactive.cpp index e5f71f5953..e7608bc945 100644 --- a/framework/interactive/internal/interactive.cpp +++ b/framework/interactive/internal/interactive.cpp @@ -329,6 +329,19 @@ static UriQuery makeSelectFileQuery(FileDialogMode mode, const std::string& titl q.set("folder", QUrl::fromLocalFile(current.toQString()).toString().toStdString()); } else if (mode == FileDialogMode::SaveFile) { q.set("currentFile", QUrl::fromLocalFile(current.toQString()).toString().toStdString()); + + // Some Linux native/portal dialogs don't auto-append the extension when the user + // doesn't type one, which then leaves the caller without a way to pick the right + // writer. Only do this when there is a single filter on offer: some callers (e.g. + // "Save As" with the experimental uncompressed-folder option) present more than one + // filter, where a global default suffix would be applied regardless of the filter + // the user actually selected, defeating the alternate option. + if (filter.size() == 1) { + std::string suffix = io::suffix(current); + if (!suffix.empty()) { + q.set("defaultSuffix", suffix); + } + } } return q;