From bfb6a8cd44978874a6e80db2c80532dbaf2ff380 Mon Sep 17 00:00:00 2001 From: Maks Naumov Date: Mon, 19 Oct 2015 20:22:01 +0300 Subject: QFileSystemModel: avoid detaching Change-Id: If7e9f11e5514b2f8975e7f83c56b606e67f5952f Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/widgets/dialogs/qfilesystemmodel.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/widgets/dialogs/qfilesystemmodel.cpp') diff --git a/src/widgets/dialogs/qfilesystemmodel.cpp b/src/widgets/dialogs/qfilesystemmodel.cpp index 7e76a6b9d7..2d8b8fadb1 100644 --- a/src/widgets/dialogs/qfilesystemmodel.cpp +++ b/src/widgets/dialogs/qfilesystemmodel.cpp @@ -243,7 +243,7 @@ QModelIndex QFileSystemModel::index(int row, int column, const QModelIndex &pare Q_ASSERT(parentNode); // now get the internal pointer for the index - QString childName = parentNode->visibleChildren[d->translateVisibleLocation(parentNode, row)]; + const QString &childName = parentNode->visibleChildren.at(d->translateVisibleLocation(parentNode, row)); const QFileSystemModelPrivate::QFileSystemNode *indexNode = parentNode->children.value(childName); Q_ASSERT(indexNode); @@ -797,7 +797,7 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const !resolvedSymLinks.isEmpty() && dirNode->isSymLink(/* ignoreNtfsSymLinks = */ true)) { QString fullPath = QDir::fromNativeSeparators(filePath(index)); if (resolvedSymLinks.contains(fullPath)) - return resolvedSymLinks[fullPath]; + return resolvedSymLinks.value(fullPath); } return dirNode->fileName; } @@ -1789,9 +1789,9 @@ void QFileSystemModelPrivate::addVisibleFiles(QFileSystemNode *parentNode, const parentNode->dirtyChildrenIndex = parentNode->visibleChildren.count(); for (int i = 0; i < newFiles.count(); ++i) { - parentNode->visibleChildren.append(newFiles.at(i)); - parentNode->children[newFiles.at(i)]->isVisible = true; - } + parentNode->visibleChildren.append(newFiles.at(i)); + parentNode->children.value(newFiles.at(i))->isVisible = true; + } if (!indexHidden) q->endInsertRows(); } @@ -1813,7 +1813,7 @@ void QFileSystemModelPrivate::removeVisibleFile(QFileSystemNode *parentNode, int if (!indexHidden) q->beginRemoveRows(parent, translateVisibleLocation(parentNode, vLocation), translateVisibleLocation(parentNode, vLocation)); - parentNode->children[parentNode->visibleChildren.at(vLocation)]->isVisible = false; + parentNode->children.value(parentNode->visibleChildren.at(vLocation))->isVisible = false; parentNode->visibleChildren.removeAt(vLocation); if (!indexHidden) q->endRemoveRows(); -- cgit v1.2.3