diff options
author | David Schulz <david.schulz@qt.io> | 2023-02-01 08:16:30 +0100 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2023-02-01 08:16:30 +0100 |
commit | 0dab651ccd98135212961aa653c256b729cfe692 (patch) | |
tree | c9c8ef9138ce03751806b84521616aa234a2e56d /src/libs/utils/fileutils.cpp | |
parent | 739d4942e2ed35fe92f11310d80632aa288fa44c (diff) | |
parent | c22b4b35e1e8205a3106dd1c9c04af6a3ea8ab7c (diff) |
Merge remote-tracking branch 'origin/9.0' into 10.0
Change-Id: I7e171601cd7317b48d5074bbc0ead127813d596c
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 14 |
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); } |