aboutsummaryrefslogtreecommitdiffstats
path: root/src/libs/utils/fileutils.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2023-02-01 08:16:30 +0100
committerDavid Schulz <david.schulz@qt.io>2023-02-01 08:16:30 +0100
commit0dab651ccd98135212961aa653c256b729cfe692 (patch)
treec9c8ef9138ce03751806b84521616aa234a2e56d /src/libs/utils/fileutils.cpp
parent739d4942e2ed35fe92f11310d80632aa288fa44c (diff)
parentc22b4b35e1e8205a3106dd1c9c04af6a3ea8ab7c (diff)
Merge remote-tracking branch 'origin/9.0' into 10.0
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r--src/libs/utils/fileutils.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp
index 44bf0bab20..efbaf912c6 100644
--- a/src/libs/utils/fileutils.cpp
+++ b/src/libs/utils/fileutils.cpp
@@ -398,26 +398,30 @@ static FilePath qUrlToFilePath(const QUrl &url)
static QUrl filePathToQUrl(const FilePath &filePath)
{
- return QUrl::fromLocalFile(filePath.toFSPathString());
+ return QUrl::fromLocalFile(filePath.toFSPathString());
}
void prepareNonNativeDialog(QFileDialog &dialog)
{
+ const auto isValidSideBarPath = [](const FilePath &fp) {
+ return !fp.needsDevice() || fp.hasFileAccess();
+ };
+
// Checking QFileDialog::itemDelegate() seems to be the only way to determine
// whether the dialog is native or not.
if (dialog.itemDelegate()) {
FilePaths sideBarPaths;
- // Check existing urls, remove paths that need a device and no longer exist.
+ // Check existing urls, remove paths that need a device and are no longer valid.
for (const QUrl &url : dialog.sidebarUrls()) {
FilePath path = qUrlToFilePath(url);
- if (!path.needsDevice() || path.exists())
+ if (isValidSideBarPath(path))
sideBarPaths.append(path);
}
- // Add all device roots that are not already in the sidebar and exist.
+ // Add all device roots that are not already in the sidebar and valid.
for (const FilePath &path : FSEngine::registeredDeviceRoots()) {
- if (!sideBarPaths.contains(path) && path.exists())
+ if (!sideBarPaths.contains(path) && isValidSideBarPath(path))
sideBarPaths.append(path);
}