diff options
author | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2023-03-28 14:23:40 +0200 |
---|---|---|
committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2023-04-02 11:24:39 +0200 |
commit | 9ddd71a6c2b6cef641f2a8cdc256fb2fbe01fa5b (patch) | |
tree | fac9fade600329851392ce0ecc4f12b5ead2eaa3 /src/plugins/platforms/ios | |
parent | 15d6244ec35c5bbdc5ed76eb787f68932f78eed6 (diff) |
QIOSFileEngineAssetsLibrary: bail out early on non-existing dirs
QFileSelector::selectionHelper walks through the list of selectors
(on iOS, on my phone it's ("ios", "iOS", "en_NO", "unix", "darwin")),
creating paths and testing QDir::exists. This ends up in asset
file engine trying to load asset for something like:
"assets-library://assets/+iOS" etc. ALAssetsLibrary -assetForUrl:
returns nil for such url and we start iterating through the assets
library. On my phone (e.g.) this takes about ~6 seconds (to iterate
through pictures/videos I have), so the image picker is dismissed
~30 seconds after an image was actually selected in a picker view,
making an impression it's completely broken. Bail out early
on such url, we know we'll fail (with AssetsLibrary giving a warning
about invalid asset with UUID(null).
Pick-to: 6.5
Fixes: QTBUG-109120
Change-Id: Ia302f4151e3aade830e647a8a260479df2b29d4b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm index 0ca911f68b..312899f3d9 100644 --- a/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm +++ b/src/plugins/platforms/ios/optional/nsphotolibrarysupport/qiosfileengineassetslibrary.mm @@ -11,6 +11,7 @@ #include <QtCore/qurl.h> #include <QtCore/qset.h> #include <QtCore/qthreadstorage.h> +#include <QtCore/qfileselector.h> QT_BEGIN_NAMESPACE @@ -344,6 +345,17 @@ QAbstractFileEngine::FileFlags QIOSFileEngineAssetsLibrary::fileFlags(QAbstractF { QAbstractFileEngine::FileFlags flags; const bool isDir = (m_assetUrl == "assets-library://"_L1); + if (!isDir) { + static const QFileSelector fileSelector; + static const auto selectors = fileSelector.allSelectors(); + if (m_assetUrl.startsWith("assets-library://"_L1)) { + for (const auto &selector : selectors) { + if (m_assetUrl.endsWith(selector)) + return flags; + } + } + } + const bool exists = isDir || m_assetUrl == g_iteratorCurrentUrl.localData() || loadAsset(); if (!exists) |