From f44a59f390be9b67365db8796aa6a54fe9241028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Sun, 10 May 2015 12:26:47 +0100 Subject: [PATCH] Don't assign iterator to const_iterator It should also be possible to use QT_STRICT_ITERATORS in Qt's own code base Change-Id: I0914db480d4d2b06e71e3a2588163efdd3ff6d27 Reviewed-by: Marc Mutz Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/corelib/tools/qcommandlineparser.cpp | 8 +-- src/gui/text/qfontengine_ft.cpp | 2 +- src/network/ssl/qasn1element.cpp | 52 +++++++++---------- .../platforms/xcb/qxcbconnection_xi2.cpp | 4 +- src/tools/qdoc/htmlgenerator.cpp | 4 +- src/tools/qdoc/node.cpp | 12 ++--- src/tools/qdoc/puredocparser.cpp | 4 +- src/tools/qdoc/qdocdatabase.cpp | 4 +- src/tools/qdoc/tree.cpp | 8 +-- 9 files changed, 49 insertions(+), 49 deletions(-) diff --git a/src/corelib/tools/qcommandlineparser.cpp b/src/corelib/tools/qcommandlineparser.cpp index 21bc14a272..0814921a58 100644 --- a/src/corelib/tools/qcommandlineparser.cpp +++ b/src/corelib/tools/qcommandlineparser.cpp @@ -115,8 +115,8 @@ public: QStringList QCommandLineParserPrivate::aliases(const QString &optionName) const { - const NameHash_t::const_iterator it = nameHash.find(optionName); - if (it == nameHash.end()) { + const NameHash_t::const_iterator it = nameHash.constFind(optionName); + if (it == nameHash.cend()) { qWarning("QCommandLineParser: option not defined: \"%s\"", qPrintable(optionName)); return QStringList(); } @@ -806,8 +806,8 @@ QString QCommandLineParser::value(const QString &optionName) const QStringList QCommandLineParser::values(const QString &optionName) const { d->checkParsed("values"); - const NameHash_t::const_iterator it = d->nameHash.find(optionName); - if (it != d->nameHash.end()) { + const NameHash_t::const_iterator it = d->nameHash.constFind(optionName); + if (it != d->nameHash.cend()) { const int optionOffset = *it; QStringList values = d->optionValuesHash.value(optionOffset); if (values.isEmpty()) diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 931c71dc63..37be0afccf 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -115,7 +115,7 @@ public: QtFreetypeData::~QtFreetypeData() { - for (QHash::ConstIterator iter = faces.begin(); iter != faces.end(); ++iter) + for (QHash::ConstIterator iter = faces.cbegin(); iter != faces.cend(); ++iter) iter.value()->cleanup(); faces.clear(); FT_Done_FreeType(library); diff --git a/src/network/ssl/qasn1element.cpp b/src/network/ssl/qasn1element.cpp index 95c360e7af..82807aec6e 100644 --- a/src/network/ssl/qasn1element.cpp +++ b/src/network/ssl/qasn1element.cpp @@ -46,32 +46,32 @@ static OidNameMap createOidMap() { OidNameMap oids; // used by unit tests - oids.insert(oids.end(), QByteArrayLiteral("0.9.2342.19200300.100.1.5"), QByteArrayLiteral("favouriteDrink")); - oids.insert(oids.end(), QByteArrayLiteral("1.2.840.113549.1.9.1"), QByteArrayLiteral("emailAddress")); - oids.insert(oids.end(), QByteArrayLiteral("1.3.6.1.5.5.7.1.1"), QByteArrayLiteral("authorityInfoAccess")); - oids.insert(oids.end(), QByteArrayLiteral("1.3.6.1.5.5.7.48.1"), QByteArrayLiteral("OCSP")); - oids.insert(oids.end(), QByteArrayLiteral("1.3.6.1.5.5.7.48.2"), QByteArrayLiteral("caIssuers")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.29.14"), QByteArrayLiteral("subjectKeyIdentifier")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.29.15"), QByteArrayLiteral("keyUsage")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.29.17"), QByteArrayLiteral("subjectAltName")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.29.19"), QByteArrayLiteral("basicConstraints")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.29.35"), QByteArrayLiteral("authorityKeyIdentifier")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.10"), QByteArrayLiteral("O")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.11"), QByteArrayLiteral("OU")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.12"), QByteArrayLiteral("title")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.13"), QByteArrayLiteral("description")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.17"), QByteArrayLiteral("postalCode")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.3"), QByteArrayLiteral("CN")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.4"), QByteArrayLiteral("SN")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.41"), QByteArrayLiteral("name")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.42"), QByteArrayLiteral("GN")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.43"), QByteArrayLiteral("initials")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.46"), QByteArrayLiteral("dnQualifier")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.5"), QByteArrayLiteral("serialNumber")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.6"), QByteArrayLiteral("C")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.7"), QByteArrayLiteral("L")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.8"), QByteArrayLiteral("ST")); - oids.insert(oids.end(), QByteArrayLiteral("2.5.4.9"), QByteArrayLiteral("street")); + oids.insert(oids.cend(), QByteArrayLiteral("0.9.2342.19200300.100.1.5"), QByteArrayLiteral("favouriteDrink")); + oids.insert(oids.cend(), QByteArrayLiteral("1.2.840.113549.1.9.1"), QByteArrayLiteral("emailAddress")); + oids.insert(oids.cend(), QByteArrayLiteral("1.3.6.1.5.5.7.1.1"), QByteArrayLiteral("authorityInfoAccess")); + oids.insert(oids.cend(), QByteArrayLiteral("1.3.6.1.5.5.7.48.1"), QByteArrayLiteral("OCSP")); + oids.insert(oids.cend(), QByteArrayLiteral("1.3.6.1.5.5.7.48.2"), QByteArrayLiteral("caIssuers")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.14"), QByteArrayLiteral("subjectKeyIdentifier")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.15"), QByteArrayLiteral("keyUsage")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.17"), QByteArrayLiteral("subjectAltName")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.19"), QByteArrayLiteral("basicConstraints")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.29.35"), QByteArrayLiteral("authorityKeyIdentifier")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.10"), QByteArrayLiteral("O")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.11"), QByteArrayLiteral("OU")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.12"), QByteArrayLiteral("title")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.13"), QByteArrayLiteral("description")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.17"), QByteArrayLiteral("postalCode")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.3"), QByteArrayLiteral("CN")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.4"), QByteArrayLiteral("SN")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.41"), QByteArrayLiteral("name")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.42"), QByteArrayLiteral("GN")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.43"), QByteArrayLiteral("initials")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.46"), QByteArrayLiteral("dnQualifier")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.5"), QByteArrayLiteral("serialNumber")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.6"), QByteArrayLiteral("C")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.7"), QByteArrayLiteral("L")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.8"), QByteArrayLiteral("ST")); + oids.insert(oids.cend(), QByteArrayLiteral("2.5.4.9"), QByteArrayLiteral("street")); return oids; } Q_GLOBAL_STATIC_WITH_ARGS(OidNameMap, oidNameMap, (createOidMap())) diff --git a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp index 0e8a162a7d..c7784ddb48 100644 --- a/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection_xi2.cpp @@ -364,8 +364,8 @@ void QXcbConnection::xi2Select(xcb_window_t window) XInput2TouchDeviceData *QXcbConnection::touchDeviceForId(int id) { XInput2TouchDeviceData *dev = Q_NULLPTR; - QHash::const_iterator devIt = m_touchDevices.find(id); - if ( devIt != m_touchDevices.end() ) { + QHash::const_iterator devIt = m_touchDevices.constFind(id); + if (devIt != m_touchDevices.cend()) { dev = devIt.value(); } else { int nrDevices = 0; diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 8d84019ab5..b340883c12 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -2199,7 +2199,7 @@ void HtmlGenerator::generateRequisites(InnerNode *inner, CodeMarker *marker) out() << "
\n"; QStringList::ConstIterator i; - for (i = requisiteorder.begin(); i != requisiteorder.constEnd(); ++i) { + for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) { if (requisites.contains(*i)) { out() << "" @@ -2319,7 +2319,7 @@ void HtmlGenerator::generateQmlRequisites(QmlTypeNode *qcn, CodeMarker *marker) out() << "
\n"; QStringList::ConstIterator i; - for (i = requisiteorder.begin(); i != requisiteorder.constEnd(); ++i) { + for (i = requisiteorder.constBegin(); i != requisiteorder.constEnd(); ++i) { if (requisites.contains(*i)) { out() << "" diff --git a/src/tools/qdoc/node.cpp b/src/tools/qdoc/node.cpp index 230ce50df8..37bc0c5fef 100644 --- a/src/tools/qdoc/node.cpp +++ b/src/tools/qdoc/node.cpp @@ -2763,8 +2763,8 @@ bool CollectionNode::hasNamespaces() const bool CollectionNode::hasClasses() const { if (!members_.isEmpty()) { - NodeList::const_iterator i = members_.begin(); - while (i != members_.end()) { + NodeList::const_iterator i = members_.cbegin(); + while (i != members_.cend()) { if ((*i)->isClass()) return true; ++i; @@ -2780,8 +2780,8 @@ bool CollectionNode::hasClasses() const void CollectionNode::getMemberNamespaces(NodeMap& out) { out.clear(); - NodeList::const_iterator i = members_.begin(); - while (i != members_.end()) { + NodeList::const_iterator i = members_.cbegin(); + while (i != members_.cend()) { if ((*i)->isNamespace()) out.insert((*i)->name(),(*i)); ++i; @@ -2795,8 +2795,8 @@ void CollectionNode::getMemberNamespaces(NodeMap& out) void CollectionNode::getMemberClasses(NodeMap& out) { out.clear(); - NodeList::const_iterator i = members_.begin(); - while (i != members_.end()) { + NodeList::const_iterator i = members_.cbegin(); + while (i != members_.cend()) { if ((*i)->isClass()) out.insert((*i)->name(),(*i)); ++i; diff --git a/src/tools/qdoc/puredocparser.cpp b/src/tools/qdoc/puredocparser.cpp index 7029431460..e47460efb2 100644 --- a/src/tools/qdoc/puredocparser.cpp +++ b/src/tools/qdoc/puredocparser.cpp @@ -188,8 +188,8 @@ bool PureDocParser::processQdocComments() topics.insert(i+1,"and"); doc.location().warning(tr("Multiple topic commands found in comment: %1").arg(topics)); } - ArgList::ConstIterator a = args.begin(); - while (a != args.end()) { + ArgList::ConstIterator a = args.cbegin(); + while (a != args.cend()) { Doc nodeDoc = doc; Node* node = processTopicCommand(nodeDoc,topic,*a); if (node != 0) { diff --git a/src/tools/qdoc/qdocdatabase.cpp b/src/tools/qdoc/qdocdatabase.cpp index f1afb92eff..bf84fa8335 100644 --- a/src/tools/qdoc/qdocdatabase.cpp +++ b/src/tools/qdoc/qdocdatabase.cpp @@ -1549,8 +1549,8 @@ void QDocDatabase::mergeCollections(Node::Genus genus, CNMap& cnm, const Node* r foreach (Tree* t, searchOrder()) { CNMap* m = t->getCollectionMap(genus); if (m && !m->isEmpty()) { - CNMap::const_iterator i = m->begin(); - while (i != m->end()) { + CNMap::const_iterator i = m->cbegin(); + while (i != m->cend()) { if (!i.value()->isInternal()) cnmm.insert(i.key(), i.value()); ++i; diff --git a/src/tools/qdoc/tree.cpp b/src/tools/qdoc/tree.cpp index 420396e51c..1b0aba1a0c 100644 --- a/src/tools/qdoc/tree.cpp +++ b/src/tools/qdoc/tree.cpp @@ -1222,8 +1222,8 @@ CollectionNode* Tree::getCollection(const QString& name, Node::Genus genus) { CNMap* m = getCollectionMap(genus); if (m) { - CNMap::const_iterator i = m->find(name); - if (i != m->end()) + CNMap::const_iterator i = m->constFind(name); + if (i != m->cend()) return i.value(); } return 0; @@ -1249,8 +1249,8 @@ CollectionNode* Tree::findCollection(const QString& name, Node::Genus genus) CNMap* m = getCollectionMap(genus); if (!m) // error return 0; - CNMap::const_iterator i = m->find(name); - if (i != m->end()) + CNMap::const_iterator i = m->constFind(name); + if (i != m->cend()) return i.value(); Node::Type t = Node::NoType; switch (genus) {