From b98c43ea602b336813fa967e610da2be100f748d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 18 Oct 2018 21:43:59 +0200 Subject: Compile with QT_STRICT_ITERATORS defined This will be the only options for Qt 6, so make sure the code compiles now. Change-Id: I23f791d1efcbd0bd33805bb4563d40460954db43 Reviewed-by: Oswald Buddenhagen --- qmake/generators/makefile.cpp | 14 +++++++------- qmake/generators/unix/unixmake2.cpp | 2 +- qmake/generators/win32/msvc_vcproj.cpp | 4 ++-- qmake/generators/win32/winmakefile.cpp | 4 ++-- qmake/property.cpp | 14 +++++++------- src/corelib/codecs/qtextcodec.cpp | 4 ++-- src/plugins/platforms/xcb/qxcbeventqueue.cpp | 6 +++--- src/tools/qlalr/lalr.h | 2 ++ .../auto/widgets/kernel/qapplication/tst_qapplication.cpp | 4 ++-- 9 files changed, 28 insertions(+), 26 deletions(-) diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index b7e591d2ab..2fbaa00f2d 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -624,7 +624,7 @@ MakefileGenerator::init() compiler.flags |= Compiler::CompilerNoCheckDeps; compilers.append(compiler); } - for (ProStringList::ConstIterator it = quc.begin(); it != quc.end(); ++it) { + for (ProStringList::ConstIterator it = quc.cbegin(); it != quc.cend(); ++it) { const ProStringList &inputs = v[ProKey(*it + ".input")]; for(x = 0; x < inputs.size(); ++x) { Compiler compiler; @@ -1878,7 +1878,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) t << ' ' << escapeDependencyPath(Option::fixPathToTargetOS( replaceExtraCompilerVariables(tmp_out, input, QString(), NoShell))); } else { - for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) { + for (ProStringList::ConstIterator input = tmp_inputs.cbegin(); input != tmp_inputs.cend(); ++input) { t << ' ' << escapeDependencyPath(Option::fixPathToTargetOS( replaceExtraCompilerVariables(tmp_out, (*input).toQString(), QString(), NoShell))); } @@ -1912,7 +1912,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) const QString del_statement("-$(DEL_FILE)"); if(!wrote_clean) { QStringList dels; - for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) { + for (ProStringList::ConstIterator input = tmp_inputs.cbegin(); input != tmp_inputs.cend(); ++input) { QString tinp = (*input).toQString(); QString out = replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell); for (const QString &rc : qAsConst(raw_clean)) { @@ -1940,7 +1940,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) if(!cleans.isEmpty()) t << valGlue(cleans, "\n\t" + del_statement, "\n\t" + del_statement, ""); if(!wrote_clean_cmds) { - for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) { + for (ProStringList::ConstIterator input = tmp_inputs.cbegin(); input != tmp_inputs.cend(); ++input) { QString tinp = (*input).toQString(); t << "\n\t" << replaceExtraCompilerVariables(tmp_clean_cmds, tinp, replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell), TargetShell); @@ -1959,7 +1959,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) QStringList deps, inputs; if(!tmp_dep.isEmpty()) deps += fileFixify(tmp_dep, FileFixifyFromOutdir); - for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) { + for (ProStringList::ConstIterator input = tmp_inputs.cbegin(); input != tmp_inputs.cend(); ++input) { QString inpf = (*input).toQString(); deps += findDependencies(inpf); inputs += Option::fixPathToTargetOS(inpf, false); @@ -2043,7 +2043,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t) t << "\n\t" << cmd << endl << endl; continue; } - for (ProStringList::ConstIterator input = tmp_inputs.begin(); input != tmp_inputs.end(); ++input) { + for (ProStringList::ConstIterator input = tmp_inputs.cbegin(); input != tmp_inputs.cend(); ++input) { QString inpf = (*input).toQString(); QString in = Option::fixPathToTargetOS(inpf, false); QStringList deps = findDependencies(inpf); @@ -3350,7 +3350,7 @@ MakefileGenerator::writePkgConfigFile() libs << "QMAKE_LIBS_PRIVATE"; libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread? t << "Libs.private:"; - for (ProStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it) + for (ProStringList::ConstIterator it = libs.cbegin(); it != libs.cend(); ++it) t << ' ' << fixLibFlags((*it).toKey()).join(' '); t << endl; } diff --git a/qmake/generators/unix/unixmake2.cpp b/qmake/generators/unix/unixmake2.cpp index d3abedb50b..4a6b5c8579 100644 --- a/qmake/generators/unix/unixmake2.cpp +++ b/qmake/generators/unix/unixmake2.cpp @@ -1485,7 +1485,7 @@ UnixMakefileGenerator::writeLibtoolFile() ProStringList libs; libs << "LIBS" << "QMAKE_LIBS"; t << "dependency_libs='"; - for (ProStringList::ConstIterator it = libs.begin(); it != libs.end(); ++it) + for (ProStringList::ConstIterator it = libs.cbegin(); it != libs.cend(); ++it) t << fixLibFlags((*it).toKey()).join(' ') << ' '; t << "'\n\n"; diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp index 6a125ccd77..d231260886 100644 --- a/qmake/generators/win32/msvc_vcproj.cpp +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -477,8 +477,8 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash 1) fprintf(stdout, "%s:", (*it).toLatin1().constData()); const ProKey pkey(*it); @@ -191,11 +191,11 @@ QMakeProperty::exec() } } } else if(Option::qmake_mode == Option::QMAKE_SET_PROPERTY) { - for(QStringList::ConstIterator it = Option::prop::properties.begin(); - it != Option::prop::properties.end(); it++) { + for (QStringList::ConstIterator it = Option::prop::properties.cbegin(); + it != Option::prop::properties.cend(); it++) { QString var = (*it); it++; - if(it == Option::prop::properties.end()) { + if (it == Option::prop::properties.cend()) { ret = false; break; } @@ -203,8 +203,8 @@ QMakeProperty::exec() setValue(var, (*it)); } } else if(Option::qmake_mode == Option::QMAKE_UNSET_PROPERTY) { - for(QStringList::ConstIterator it = Option::prop::properties.begin(); - it != Option::prop::properties.end(); it++) { + for (QStringList::ConstIterator it = Option::prop::properties.cbegin(); + it != Option::prop::properties.cend(); it++) { QString var = (*it); if(!var.startsWith(".")) remove(var); diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index 466c575c3e..3fc199c0a1 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -505,9 +505,9 @@ QTextCodec::~QTextCodec() globalData->allCodecs.removeOne(this); - auto it = globalData->codecCache.cbegin(); + auto it = globalData->codecCache.begin(); - while (it != globalData->codecCache.cend()) { + while (it != globalData->codecCache.end()) { if (it.value() == this) it = globalData->codecCache.erase(it); else diff --git a/src/plugins/platforms/xcb/qxcbeventqueue.cpp b/src/plugins/platforms/xcb/qxcbeventqueue.cpp index 862f68764b..883268b083 100644 --- a/src/plugins/platforms/xcb/qxcbeventqueue.cpp +++ b/src/plugins/platforms/xcb/qxcbeventqueue.cpp @@ -257,7 +257,7 @@ qint32 QXcbEventQueue::generatePeekerId() bool QXcbEventQueue::removePeekerId(qint32 peekerId) { - const auto it = m_peekerToNode.find(peekerId); + const auto it = m_peekerToNode.constFind(peekerId); if (it == m_peekerToNode.constEnd()) { qCWarning(lcQpaXcb, "failed to remove unknown peeker id: %d", peekerId); return false; @@ -276,7 +276,7 @@ bool QXcbEventQueue::peekEventQueue(PeekerCallback peeker, void *peekerData, const bool peekerIdProvided = peekerId != -1; auto peekerToNodeIt = m_peekerToNode.find(peekerId); - if (peekerIdProvided && peekerToNodeIt == m_peekerToNode.constEnd()) { + if (peekerIdProvided && peekerToNodeIt == m_peekerToNode.end()) { qCWarning(lcQpaXcb, "failed to find index for unknown peeker id: %d", peekerId); return false; } @@ -336,7 +336,7 @@ bool QXcbEventQueue::peekEventQueue(PeekerCallback peeker, void *peekerData, // Before updating, make sure that a peeker callback did not remove // the peeker id. peekerToNodeIt = m_peekerToNode.find(peekerId); - if (peekerToNodeIt != m_peekerToNode.constEnd()) + if (peekerToNodeIt != m_peekerToNode.end()) *peekerToNodeIt = node; // id still in the cache, update node } diff --git a/src/tools/qlalr/lalr.h b/src/tools/qlalr/lalr.h index 6a2baaa462..8eadee400d 100644 --- a/src/tools/qlalr/lalr.h +++ b/src/tools/qlalr/lalr.h @@ -61,6 +61,8 @@ public: public: const_iterator () {} + const_iterator (const typename _Base::iterator &it): + _M_iterator (typename _Base::const_iterator(it)) {} const_iterator (const typename _Base::const_iterator &it): _M_iterator (it) {} diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index d06baed322..e2ef5635c2 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -360,8 +360,8 @@ void tst_QApplication::setFont_data() int cnt = 0; QFontDatabase fdb; QStringList families = fdb.families(); - for (QStringList::const_iterator itr = families.begin(); - itr != families.end(); + for (QStringList::const_iterator itr = families.cbegin(); + itr != families.cend(); ++itr) { if (cnt < 3) { QString family = *itr; -- cgit v1.2.3