diff options
author | Ilya Fedin <fedin-ilja2010@ya.ru> | 2022-09-10 00:22:41 +0400 |
---|---|---|
committer | Ilya Fedin <fedin-ilja2010@ya.ru> | 2022-09-10 19:35:20 +0400 |
commit | 798d2fceaddfcddcc1c59299854cd10172c8eab8 (patch) | |
tree | 4f9df8f91f179949427618583d04528964d3e213 | |
parent | 42f1166a7f2bba2b198e54c7c7c7879e885f2d5a (diff) | |
download | qtbase-798d2fceaddfcddcc1c59299854cd10172c8eab8.tar.gz |
FileChooser portal: set current_file only when file already exists
According to xdg-desktop-portal documentation, current_file should be set
only when such a file already exists and xdg-desktop-portal-gnome enforces
this by being totally broken when current_file is set to a non-existent path
Change-Id: Ie3c80a7c6fd0cf23eea88ddec2149f5904c63394
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 7927b05b2fed0d6004435fcb48954f609de288ca)
-rw-r--r-- | src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp index 973ede3fef..3fa5b03143 100644 --- a/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp +++ b/src/plugins/platformthemes/xdgdesktopportal/qxdgdesktopportalfiledialog.cpp @@ -207,9 +207,12 @@ void QXdgDesktopPortalFileDialog::openPortal(Qt::WindowFlags windowFlags, Qt::Wi if (!d->selectedFiles.isEmpty()) { // current_file for the file to be pre-selected, current_name for the file name to be pre-filled - // current_file accepts absolute path while current_name accepts just file name - options.insert(QLatin1String("current_file"), QFile::encodeName(d->selectedFiles.first()).append('\0')); - options.insert(QLatin1String("current_name"), QFileInfo(d->selectedFiles.first()).fileName()); + // current_file accepts absolute path and requires the file to exist + // while current_name accepts just file name + QFileInfo selectedFileInfo(d->selectedFiles.first()); + if (selectedFileInfo.exists()) + options.insert(QLatin1String("current_file"), QFile::encodeName(d->selectedFiles.first()).append('\0')); + options.insert(QLatin1String("current_name"), selectedFileInfo.fileName()); } } |