From c3f5744d2e0a2cd907c0601240d188b583ae79cb Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 1 Apr 2015 13:41:21 +0200 Subject: Don't mix iterator and const_iterator Add QT_STRICT_ITERATORS to disallow implicit conversions between iterator and const_iterator. This avoids potential detaches of the Qt containers. Change-Id: I79d381f531ddda9ac402c6f5c63cdc7c6808a0bd Reviewed-by: Karsten Heimrich --- installerfw.pri | 2 +- src/libs/installer/licenseoperation.cpp | 4 ++-- src/libs/installer/packagemanagercore_p.cpp | 2 +- src/libs/installer/packagemanagerproxyfactory.cpp | 2 +- tools/common/repositorygen.cpp | 2 +- tools/repocompare/repositorymanager.cpp | 4 ++-- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/installerfw.pri b/installerfw.pri index bed0451a9..a0506715e 100644 --- a/installerfw.pri +++ b/installerfw.pri @@ -112,7 +112,7 @@ CONFIG(static, static|shared) { CONFIG += depend_includepath no_private_qt_headers_warning c++11 GIT_SHA1 = $$system(git rev-list --abbrev-commit -n1 HEAD) -DEFINES += QT_NO_CAST_FROM_ASCII QT_USE_QSTRINGBUILDER "_GIT_SHA1_=$$GIT_SHA1" \ +DEFINES += QT_NO_CAST_FROM_ASCII QT_STRICT_ITERATORS QT_USE_QSTRINGBUILDER "_GIT_SHA1_=$$GIT_SHA1" \ IFW_VERSION_STR=$$IFW_VERSION_STR IFW_VERSION=$$IFW_VERSION DEFINES += IFW_REPOSITORY_FORMAT_VERSION=$$IFW_REPOSITORY_FORMAT_VERSION diff --git a/src/libs/installer/licenseoperation.cpp b/src/libs/installer/licenseoperation.cpp index 9f4a232f8..dc39d5ecf 100644 --- a/src/libs/installer/licenseoperation.cpp +++ b/src/libs/installer/licenseoperation.cpp @@ -75,7 +75,7 @@ bool LicenseOperation::performOperation() dir.mkpath(targetDir); setArguments(QStringList(targetDir)); - for (QVariantMap::const_iterator it = licenses.begin(); it != licenses.end(); ++it) { + for (QVariantMap::const_iterator it = licenses.constBegin(); it != licenses.constEnd(); ++it) { QFile file(targetDir + QDir::separator() + it.key()); if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) { setError(UserDefinedError); @@ -93,7 +93,7 @@ bool LicenseOperation::performOperation() bool LicenseOperation::undoOperation() { - QVariantMap licenses = value(QLatin1String("licenses")).toMap(); + const QVariantMap licenses = value(QLatin1String("licenses")).toMap(); if (licenses.isEmpty()) { setError(UserDefinedError); setErrorString(tr("No license files found to delete.")); diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index c4210644c..a97c83226 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -343,7 +343,7 @@ bool PackageManagerCorePrivate::buildComponentTree(QHash &c return false; // append all components to their respective parents QHash::const_iterator it; - for (it = components.begin(); it != components.end(); ++it) { + for (it = components.constBegin(); it != components.constEnd(); ++it) { QString id = it.key(); QInstaller::Component *component = it.value(); while (!id.isEmpty() && component->parentComponent() == 0) { diff --git a/src/libs/installer/packagemanagerproxyfactory.cpp b/src/libs/installer/packagemanagerproxyfactory.cpp index 15e18c889..5e8e3188b 100644 --- a/src/libs/installer/packagemanagerproxyfactory.cpp +++ b/src/libs/installer/packagemanagerproxyfactory.cpp @@ -109,7 +109,7 @@ void PackageManagerProxyFactory::setProxyCredentials(const QNetworkProxy &proxy, auto p = std::find_if(m_proxyCredentials.begin(), m_proxyCredentials.end(), FindProxyCredential(proxy.hostName(), proxy.port())); - if (p == m_proxyCredentials.constEnd()) { + if (p == m_proxyCredentials.end()) { ProxyCredential proxyCredential; proxyCredential.host = proxy.hostName(); proxyCredential.port = proxy.port(); diff --git a/tools/common/repositorygen.cpp b/tools/common/repositorygen.cpp index 1863286cf..19f4003a4 100644 --- a/tools/common/repositorygen.cpp +++ b/tools/common/repositorygen.cpp @@ -394,7 +394,7 @@ PackageInfoVector QInstallerTools::createListOfPackages(const QStringList &packa QFileInfoList entries; foreach (const QString &packagesDirectory, packagesDirectories) entries.append(QDir(packagesDirectory).entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot)); - for (QFileInfoList::const_iterator it = entries.begin(); it != entries.end(); ++it) { + for (QFileInfoList::const_iterator it = entries.constBegin(); it != entries.constEnd(); ++it) { if (filterType == Exclude) { // Check for current file in exclude list, if found, skip it and remove it from exclude list if (packagesToFilter->contains(it->fileName())) { diff --git a/tools/repocompare/repositorymanager.cpp b/tools/repocompare/repositorymanager.cpp index 24a41a63c..12df728f4 100644 --- a/tools/repocompare/repositorymanager.cpp +++ b/tools/repocompare/repositorymanager.cpp @@ -191,8 +191,8 @@ void RepositoryManager::writeUpdateFile(const QString &fileName) } QStringList items; - for (QMap::const_iterator it = updateMap.begin(); it != updateMap.end(); - ++it) { + for (QMap::const_iterator it = updateMap.constBegin(); + it != updateMap.constEnd(); ++it) { if (it.value().update) items.append(it.key()); } -- cgit v1.2.3