summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2015-04-01 13:41:21 +0200
committerKai Koehne <kai.koehne@theqtcompany.com>2015-04-08 08:36:57 +0000
commitc3f5744d2e0a2cd907c0601240d188b583ae79cb (patch)
tree1894ba867a12f77a4927d8c20549ae537556e555
parentce703ed61b42bebe1e43a0e2ee00e815503edf20 (diff)
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 <karsten.heimrich@theqtcompany.com>
-rw-r--r--installerfw.pri2
-rw-r--r--src/libs/installer/licenseoperation.cpp4
-rw-r--r--src/libs/installer/packagemanagercore_p.cpp2
-rw-r--r--src/libs/installer/packagemanagerproxyfactory.cpp2
-rw-r--r--tools/common/repositorygen.cpp2
-rw-r--r--tools/repocompare/repositorymanager.cpp4
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<QString, Component*> &c
return false;
// append all components to their respective parents
QHash<QString, Component*>::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<QString, ComponentDescription>::const_iterator it = updateMap.begin(); it != updateMap.end();
- ++it) {
+ for (QMap<QString, ComponentDescription>::const_iterator it = updateMap.constBegin();
+ it != updateMap.constEnd(); ++it) {
if (it.value().update)
items.append(it.key());
}