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 <oswald.buddenhagen@qt.io>
This commit is contained in:
Lars Knoll 2018-10-18 21:43:59 +02:00
parent c2bf0cac95
commit b98c43ea60
9 changed files with 28 additions and 26 deletions

View File

@ -624,7 +624,7 @@ MakefileGenerator::init()
compiler.flags |= Compiler::CompilerNoCheckDeps; compiler.flags |= Compiler::CompilerNoCheckDeps;
compilers.append(compiler); 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")]; const ProStringList &inputs = v[ProKey(*it + ".input")];
for(x = 0; x < inputs.size(); ++x) { for(x = 0; x < inputs.size(); ++x) {
Compiler compiler; Compiler compiler;
@ -1878,7 +1878,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
t << ' ' << escapeDependencyPath(Option::fixPathToTargetOS( t << ' ' << escapeDependencyPath(Option::fixPathToTargetOS(
replaceExtraCompilerVariables(tmp_out, input, QString(), NoShell))); replaceExtraCompilerVariables(tmp_out, input, QString(), NoShell)));
} else { } 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( t << ' ' << escapeDependencyPath(Option::fixPathToTargetOS(
replaceExtraCompilerVariables(tmp_out, (*input).toQString(), QString(), NoShell))); replaceExtraCompilerVariables(tmp_out, (*input).toQString(), QString(), NoShell)));
} }
@ -1912,7 +1912,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
const QString del_statement("-$(DEL_FILE)"); const QString del_statement("-$(DEL_FILE)");
if(!wrote_clean) { if(!wrote_clean) {
QStringList dels; 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 tinp = (*input).toQString();
QString out = replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell); QString out = replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell);
for (const QString &rc : qAsConst(raw_clean)) { for (const QString &rc : qAsConst(raw_clean)) {
@ -1940,7 +1940,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
if(!cleans.isEmpty()) if(!cleans.isEmpty())
t << valGlue(cleans, "\n\t" + del_statement, "\n\t" + del_statement, ""); t << valGlue(cleans, "\n\t" + del_statement, "\n\t" + del_statement, "");
if(!wrote_clean_cmds) { 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(); QString tinp = (*input).toQString();
t << "\n\t" << replaceExtraCompilerVariables(tmp_clean_cmds, tinp, t << "\n\t" << replaceExtraCompilerVariables(tmp_clean_cmds, tinp,
replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell), TargetShell); replaceExtraCompilerVariables(tmp_out, tinp, QString(), NoShell), TargetShell);
@ -1959,7 +1959,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
QStringList deps, inputs; QStringList deps, inputs;
if(!tmp_dep.isEmpty()) if(!tmp_dep.isEmpty())
deps += fileFixify(tmp_dep, FileFixifyFromOutdir); 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(); QString inpf = (*input).toQString();
deps += findDependencies(inpf); deps += findDependencies(inpf);
inputs += Option::fixPathToTargetOS(inpf, false); inputs += Option::fixPathToTargetOS(inpf, false);
@ -2043,7 +2043,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
t << "\n\t" << cmd << endl << endl; t << "\n\t" << cmd << endl << endl;
continue; 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 inpf = (*input).toQString();
QString in = Option::fixPathToTargetOS(inpf, false); QString in = Option::fixPathToTargetOS(inpf, false);
QStringList deps = findDependencies(inpf); QStringList deps = findDependencies(inpf);
@ -3350,7 +3350,7 @@ MakefileGenerator::writePkgConfigFile()
libs << "QMAKE_LIBS_PRIVATE"; libs << "QMAKE_LIBS_PRIVATE";
libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread? libs << "QMAKE_LFLAGS_THREAD"; //not sure about this one, but what about things like -pthread?
t << "Libs.private:"; 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 << ' ' << fixLibFlags((*it).toKey()).join(' ');
t << endl; t << endl;
} }

View File

@ -1485,7 +1485,7 @@ UnixMakefileGenerator::writeLibtoolFile()
ProStringList libs; ProStringList libs;
libs << "LIBS" << "QMAKE_LIBS"; libs << "LIBS" << "QMAKE_LIBS";
t << "dependency_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 << fixLibFlags((*it).toKey()).join(' ') << ' ';
t << "'\n\n"; t << "'\n\n";

View File

@ -477,8 +477,8 @@ ProStringList VcprojGenerator::collectDependencies(QMakeProject *proj, QHash<QSt
// Add all unknown libs to the deps // Add all unknown libs to the deps
QStringList where = QStringList() << "LIBS" << "LIBS_PRIVATE" QStringList where = QStringList() << "LIBS" << "LIBS_PRIVATE"
<< "QMAKE_LIBS" << "QMAKE_LIBS_PRIVATE"; << "QMAKE_LIBS" << "QMAKE_LIBS_PRIVATE";
for (QStringList::ConstIterator wit = where.begin(); for (QStringList::ConstIterator wit = where.cbegin();
wit != where.end(); ++wit) { wit != where.cend(); ++wit) {
const ProStringList &l = tmp_proj.values(ProKey(*wit)); const ProStringList &l = tmp_proj.values(ProKey(*wit));
for (ProStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { for (ProStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
const QString opt = fixLibFlag(*it).toQString(); const QString opt = fixLibFlag(*it).toQString();

View File

@ -112,8 +112,8 @@ Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
goto found; goto found;
} }
QString libBase = (*dir_it).local() + '/' + lib + verovr; QString libBase = (*dir_it).local() + '/' + lib + verovr;
for (ProStringList::ConstIterator extit = impexts.begin(); for (ProStringList::ConstIterator extit = impexts.cbegin();
extit != impexts.end(); ++extit) { extit != impexts.cend(); ++extit) {
if (exists(libBase + '.' + *extit)) { if (exists(libBase + '.' + *extit)) {
(*it) = cand + verovr + '.' + *extit; (*it) = cand + verovr + '.' + *extit;
goto found; goto found;

View File

@ -178,8 +178,8 @@ QMakeProperty::exec()
} }
return true; return true;
} }
for(QStringList::ConstIterator it = Option::prop::properties.begin(); for (QStringList::ConstIterator it = Option::prop::properties.cbegin();
it != Option::prop::properties.end(); it++) { it != Option::prop::properties.cend(); it++) {
if(Option::prop::properties.count() > 1) if(Option::prop::properties.count() > 1)
fprintf(stdout, "%s:", (*it).toLatin1().constData()); fprintf(stdout, "%s:", (*it).toLatin1().constData());
const ProKey pkey(*it); const ProKey pkey(*it);
@ -191,11 +191,11 @@ QMakeProperty::exec()
} }
} }
} else if(Option::qmake_mode == Option::QMAKE_SET_PROPERTY) { } else if(Option::qmake_mode == Option::QMAKE_SET_PROPERTY) {
for(QStringList::ConstIterator it = Option::prop::properties.begin(); for (QStringList::ConstIterator it = Option::prop::properties.cbegin();
it != Option::prop::properties.end(); it++) { it != Option::prop::properties.cend(); it++) {
QString var = (*it); QString var = (*it);
it++; it++;
if(it == Option::prop::properties.end()) { if (it == Option::prop::properties.cend()) {
ret = false; ret = false;
break; break;
} }
@ -203,8 +203,8 @@ QMakeProperty::exec()
setValue(var, (*it)); setValue(var, (*it));
} }
} else if(Option::qmake_mode == Option::QMAKE_UNSET_PROPERTY) { } else if(Option::qmake_mode == Option::QMAKE_UNSET_PROPERTY) {
for(QStringList::ConstIterator it = Option::prop::properties.begin(); for (QStringList::ConstIterator it = Option::prop::properties.cbegin();
it != Option::prop::properties.end(); it++) { it != Option::prop::properties.cend(); it++) {
QString var = (*it); QString var = (*it);
if(!var.startsWith(".")) if(!var.startsWith("."))
remove(var); remove(var);

View File

@ -505,9 +505,9 @@ QTextCodec::~QTextCodec()
globalData->allCodecs.removeOne(this); 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) if (it.value() == this)
it = globalData->codecCache.erase(it); it = globalData->codecCache.erase(it);
else else

View File

@ -257,7 +257,7 @@ qint32 QXcbEventQueue::generatePeekerId()
bool QXcbEventQueue::removePeekerId(qint32 peekerId) bool QXcbEventQueue::removePeekerId(qint32 peekerId)
{ {
const auto it = m_peekerToNode.find(peekerId); const auto it = m_peekerToNode.constFind(peekerId);
if (it == m_peekerToNode.constEnd()) { if (it == m_peekerToNode.constEnd()) {
qCWarning(lcQpaXcb, "failed to remove unknown peeker id: %d", peekerId); qCWarning(lcQpaXcb, "failed to remove unknown peeker id: %d", peekerId);
return false; return false;
@ -276,7 +276,7 @@ bool QXcbEventQueue::peekEventQueue(PeekerCallback peeker, void *peekerData,
const bool peekerIdProvided = peekerId != -1; const bool peekerIdProvided = peekerId != -1;
auto peekerToNodeIt = m_peekerToNode.find(peekerId); 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); qCWarning(lcQpaXcb, "failed to find index for unknown peeker id: %d", peekerId);
return false; return false;
} }
@ -336,7 +336,7 @@ bool QXcbEventQueue::peekEventQueue(PeekerCallback peeker, void *peekerData,
// Before updating, make sure that a peeker callback did not remove // Before updating, make sure that a peeker callback did not remove
// the peeker id. // the peeker id.
peekerToNodeIt = m_peekerToNode.find(peekerId); peekerToNodeIt = m_peekerToNode.find(peekerId);
if (peekerToNodeIt != m_peekerToNode.constEnd()) if (peekerToNodeIt != m_peekerToNode.end())
*peekerToNodeIt = node; // id still in the cache, update node *peekerToNodeIt = node; // id still in the cache, update node
} }

View File

@ -61,6 +61,8 @@ public:
public: public:
const_iterator () {} const_iterator () {}
const_iterator (const typename _Base::iterator &it):
_M_iterator (typename _Base::const_iterator(it)) {}
const_iterator (const typename _Base::const_iterator &it): const_iterator (const typename _Base::const_iterator &it):
_M_iterator (it) {} _M_iterator (it) {}

View File

@ -360,8 +360,8 @@ void tst_QApplication::setFont_data()
int cnt = 0; int cnt = 0;
QFontDatabase fdb; QFontDatabase fdb;
QStringList families = fdb.families(); QStringList families = fdb.families();
for (QStringList::const_iterator itr = families.begin(); for (QStringList::const_iterator itr = families.cbegin();
itr != families.end(); itr != families.cend();
++itr) { ++itr) {
if (cnt < 3) { if (cnt < 3) {
QString family = *itr; QString family = *itr;