summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2023-01-20 09:54:25 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-15 09:50:56 +0000
commit86c9c914c2150936d7dc9c6e4221932d5873a12f (patch)
tree3527410944ab90981dad1e6d840db618ab1ba8a3
parentFix few QFileInfo and QDir calls (diff)
downloadqtbase-86c9c914c2150936d7dc9c6e4221932d5873a12f.tar.xz
qtbase-86c9c914c2150936d7dc9c6e4221932d5873a12f.zip
QIosFileDialog - properly handle QUrl for assets-library
For QT_PLATFORM_UIKIT 'PicturesLocation' manually appended by "assets-library://". When converted to QUrl, such a path becomes a valid url, having empty path and scheme "assets-library". Later in QIOSFileDialog we convert this path (options()->initialDirectory()) calling QUrl::toLocalPath, which gives us an empty string and thus we erroneusly select document picker dialog, not an image picker. So let's also check a scheme, not path only. Fixes: QTBUG-107844 Change-Id: If4dd453549b37933cba07b5d7af6e45f2504dd29 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> (cherry picked from commit 402a526b2a87cbf6b7466bacb9dd3d8b7c71d9b2) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/plugins/platforms/ios/qiosfiledialog.mm10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/plugins/platforms/ios/qiosfiledialog.mm b/src/plugins/platforms/ios/qiosfiledialog.mm
index 64e9445c43..64c42e0cc4 100644
--- a/src/plugins/platforms/ios/qiosfiledialog.mm
+++ b/src/plugins/platforms/ios/qiosfiledialog.mm
@@ -36,11 +36,15 @@ bool QIOSFileDialog::show(Qt::WindowFlags windowFlags, Qt::WindowModality window
Q_UNUSED(windowFlags);
Q_UNUSED(windowModality);
- bool acceptOpen = options()->acceptMode() == QFileDialogOptions::AcceptOpen;
- QString directory = options()->initialDirectory().toLocalFile();
+ const bool acceptOpen = options()->acceptMode() == QFileDialogOptions::AcceptOpen;
+ const auto initialDir = options()->initialDirectory();
+ const QString directory = initialDir.toLocalFile();
+ // We manually add assets-library:// to the list of paths,
+ // when converted to QUrl, it becames a scheme.
+ const QString scheme = initialDir.scheme();
if (acceptOpen) {
- if (directory.startsWith("assets-library:"_L1))
+ if (directory.startsWith("assets-library:"_L1) || scheme == "assets-library"_L1)
return showImagePickerDialog(parent);
else
return showNativeDocumentPickerDialog(parent);