summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDongmei Wang <dongmei.wang@qt.io>2018-11-09 00:07:58 -0800
committerKarsten Heimrich <karsten.heimrich@qt.io>2021-05-26 18:58:34 +0200
commit95694109e9ec8200239f9a9aae7a789fe565c5e9 (patch)
tree4a5fa91839caf7658402ca48124ad824fe034cce /src
parent2d929d01162e0ca191e220b03c61ec7e215e75e1 (diff)
QFileSystemModel fails to locate a host from root's visible children
In QFileSystemModel, in some cases the hostname in a UNC path is converted to lower case and stored in the root node's visibleChildren. When QFileSystemModel sets the UNC path as the root path, it tries to get the row number for the host, but it didn't convert the hostname to lower case before getting the row number, which resulted in the host not found in the root node's visible children. As a result, it returns -1, an invalid row number. Change the behavior to find the node for the host using the host name case-insensitive and then get the row number. Fixes: QTBUG-71701 Change-Id: Ib95c7b6d2bc22fd82f2789b7004b6fc82dfcb13b Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alex Blasche <alexander.blasche@qt.io> (cherry picked from commit e253a30238ed1a93877780428c035d3b7a53e22a) Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/dialogs/qfilesystemmodel.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp
index 9ee2b94f15..d70b07f8ca 100644
--- a/src/widgets/dialogs/qfilesystemmodel.cpp
+++ b/src/widgets/dialogs/qfilesystemmodel.cpp
@@ -397,8 +397,11 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
if (absolutePath.endsWith(QLatin1Char('/')))
trailingSeparator = QLatin1String("\\");
int r = 0;
- QFileSystemModelPrivate::QFileSystemNode *rootNode = const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
- if (!root.children.contains(host.toLower())) {
+ auto rootNode = const_cast<QFileSystemModelPrivate::QFileSystemNode*>(&root);
+ auto it = root.children.constFind(host);
+ if (it != root.children.cend()) {
+ host = it.key(); // Normalize case for lookup in visibleLocation()
+ } else {
if (pathElements.count() == 1 && !absolutePath.endsWith(QLatin1Char('/')))
return rootNode;
QFileInfo info(host);