Commit 056e8aa4 authored by Friedemann Kleint's avatar Friedemann Kleint
Browse files

Fix some Krazy warnings about non-const ref iterator.



Change-Id: I1c78f5f5a7174002cd25bea109d5fe795530cdb5
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 28413a81
...@@ -258,7 +258,7 @@ QString Environment::searchInPath(const QString &executable, ...@@ -258,7 +258,7 @@ QString Environment::searchInPath(const QString &executable,
} }
} }
foreach (QString dir, additionalDirs) { foreach (const QString &dir, additionalDirs) {
QString tmp = searchInDirectory(execs, dir); QString tmp = searchInDirectory(execs, dir);
if (!tmp.isEmpty()) if (!tmp.isEmpty())
return tmp; return tmp;
......
...@@ -87,7 +87,7 @@ JsonValue *JsonValue::build(const QVariant &variant) ...@@ -87,7 +87,7 @@ JsonValue *JsonValue::build(const QVariant &variant)
case QVariant::List: { case QVariant::List: {
JsonArrayValue *newValue = new JsonArrayValue; JsonArrayValue *newValue = new JsonArrayValue;
foreach (const QVariant element, variant.toList()) foreach (const QVariant &element, variant.toList())
newValue->addElement(build(element)); newValue->addElement(build(element));
return newValue; return newValue;
} }
......
...@@ -74,7 +74,7 @@ QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Loca ...@@ -74,7 +74,7 @@ QList<Locator::FilterEntry> CMakeLocatorFilter::matchesFor(QFutureInterface<Loca
foreach (ProjectExplorer::Project *p, projects) { foreach (ProjectExplorer::Project *p, projects) {
CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p); CMakeProject *cmakeProject = qobject_cast<CMakeProject *>(p);
if (cmakeProject) { if (cmakeProject) {
foreach (CMakeBuildTarget ct, cmakeProject->buildTargets()) { foreach (const CMakeBuildTarget &ct, cmakeProject->buildTargets()) {
if (ct.title.contains(entry)) { if (ct.title.contains(entry)) {
Locator::FilterEntry entry(this, ct.title, cmakeProject->document()->fileName()); Locator::FilterEntry entry(this, ct.title, cmakeProject->document()->fileName());
entry.extraInfo = FileUtils::shortNativePath( entry.extraInfo = FileUtils::shortNativePath(
......
...@@ -2675,7 +2675,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response) ...@@ -2675,7 +2675,7 @@ void GdbEngine::handleBreakInsert1(const GdbResponse &response)
BreakpointResponseId rid(nr); BreakpointResponseId rid(nr);
if (!isHiddenBreakpoint(rid)) { if (!isHiddenBreakpoint(rid)) {
BreakpointResponse br = handler->response(id); BreakpointResponse br = handler->response(id);
foreach (const GdbMi bkpt, response.data.children()) { foreach (const GdbMi &bkpt, response.data.children()) {
nr = bkpt.findChild("number").data(); nr = bkpt.findChild("number").data();
rid = BreakpointResponseId(nr); rid = BreakpointResponseId(nr);
QTC_ASSERT(rid.isValid(), continue); QTC_ASSERT(rid.isValid(), continue);
...@@ -3518,7 +3518,7 @@ void GdbEngine::handleModulesList(const GdbResponse &response) ...@@ -3518,7 +3518,7 @@ void GdbEngine::handleModulesList(const GdbResponse &response)
void GdbEngine::examineModules() void GdbEngine::examineModules()
{ {
ModulesHandler *handler = modulesHandler(); ModulesHandler *handler = modulesHandler();
foreach (Module module, handler->modules()) { foreach (const Module &module, handler->modules()) {
if (module.elfData.symbolsType == UnknownSymbols) if (module.elfData.symbolsType == UnknownSymbols)
handler->updateModule(module); handler->updateModule(module);
} }
......
...@@ -467,7 +467,7 @@ void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value, ...@@ -467,7 +467,7 @@ void QmlInspectorAgent::onResult(quint32 queryId, const QVariant &value,
m_objectTreeQueryIds.removeOne(queryId); m_objectTreeQueryIds.removeOne(queryId);
if (value.type() == QVariant::List) { if (value.type() == QVariant::List) {
QVariantList objList = value.toList(); QVariantList objList = value.toList();
foreach (QVariant var, objList) { foreach (const QVariant &var, objList) {
// TODO: check which among the list is the actual // TODO: check which among the list is the actual
// object that needs to be selected. // object that needs to be selected.
verifyAndInsertObjectInTree(qvariant_cast<ObjectReference>(var)); verifyAndInsertObjectInTree(qvariant_cast<ObjectReference>(var));
......
...@@ -77,7 +77,7 @@ static inline void getProperties(const ModelNode node, QHash<PropertyName, QVari ...@@ -77,7 +77,7 @@ static inline void getProperties(const ModelNode node, QHash<PropertyName, QVari
static inline void applyProperties(ModelNode &node, const QHash<PropertyName, QVariant> &propertyHash) static inline void applyProperties(ModelNode &node, const QHash<PropertyName, QVariant> &propertyHash)
{ {
QHash<PropertyName, QVariant> auxiliaryData = node.auxiliaryData(); QHash<PropertyName, QVariant> auxiliaryData = node.auxiliaryData();
foreach (const PropertyName propertyName, auxiliaryData.keys()) { foreach (const PropertyName &propertyName, auxiliaryData.keys()) {
node.setAuxiliaryData(propertyName, QVariant()); node.setAuxiliaryData(propertyName, QVariant());
} }
......
...@@ -212,7 +212,7 @@ void SubComponentManager::parseDirectories() ...@@ -212,7 +212,7 @@ void SubComponentManager::parseDirectories()
if (dirInfo.exists() && dirInfo.isDir()) if (dirInfo.exists() && dirInfo.isDir())
parseDirectory(dirInfo.canonicalFilePath()); parseDirectory(dirInfo.canonicalFilePath());
foreach (const QString subDir, QDir(QFileInfo(file).path()).entryList(QDir::Dirs | QDir::NoDot | QDir::NoDotDot)) { foreach (const QString &subDir, QDir(QFileInfo(file).path()).entryList(QDir::Dirs | QDir::NoDot | QDir::NoDotDot)) {
parseDirectory(dirInfo.canonicalFilePath() + "/" + subDir, true, subDir.toUtf8()); parseDirectory(dirInfo.canonicalFilePath() + "/" + subDir, true, subDir.toUtf8());
} }
} }
......
...@@ -717,7 +717,7 @@ QString RewriterView::pathForImport(const Import &import) ...@@ -717,7 +717,7 @@ QString RewriterView::pathForImport(const Import &import)
QmlJS::ImportInfo importInfo; QmlJS::ImportInfo importInfo;
foreach (QmlJS::Import qmljsImport, imports->all()) { foreach (const QmlJS::Import &qmljsImport, imports->all()) {
if (qmljsImport.info.name() == importStr) if (qmljsImport.info.name() == importStr)
importInfo = qmljsImport.info; importInfo = qmljsImport.info;
} }
......
...@@ -668,7 +668,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface ...@@ -668,7 +668,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const IAssistInterface
QStringList nCompletions; QStringList nCompletions;
QString prefix(libVersion.left(toSkip)); QString prefix(libVersion.left(toSkip));
nCompletions.reserve(completions.size()); nCompletions.reserve(completions.size());
foreach (QString completion, completions) foreach (const QString &completion, completions)
if (completion.startsWith(prefix)) if (completion.startsWith(prefix))
nCompletions.append(completion.right(completion.size()-toSkip)); nCompletions.append(completion.right(completion.size()-toSkip));
completions = nCompletions; completions = nCompletions;
......
...@@ -135,7 +135,7 @@ void BlackBerryConfiguration::loadCertificates() ...@@ -135,7 +135,7 @@ void BlackBerryConfiguration::loadCertificates()
settings->beginGroup(SettingsGroup); settings->beginGroup(SettingsGroup);
settings->beginGroup(CertificateGroup); settings->beginGroup(CertificateGroup);
foreach (QString certificateId, settings->childGroups()) { foreach (const QString &certificateId, settings->childGroups()) {
settings->beginGroup(certificateId); settings->beginGroup(certificateId);
BlackBerryCertificate *cert = BlackBerryCertificate *cert =
......
...@@ -382,8 +382,9 @@ void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const ...@@ -382,8 +382,9 @@ void RefactoringFile::indentOrReindent(void (RefactoringChangesData::*mf)(const
const BaseTextEditorWidget *) const, const BaseTextEditorWidget *) const,
const QList<QPair<QTextCursor, QTextCursor> > &ranges) const QList<QPair<QTextCursor, QTextCursor> > &ranges)
{ {
QPair<QTextCursor, QTextCursor> p; typedef QPair<QTextCursor, QTextCursor> CursorPair;
foreach (p, ranges) {
foreach (const CursorPair &p, ranges) {
QTextCursor selection(p.first.document()); QTextCursor selection(p.first.document());
selection.setPosition(p.first.position()); selection.setPosition(p.first.position());
selection.setPosition(p.second.position(), QTextCursor::KeepAnchor); selection.setPosition(p.second.position(), QTextCursor::KeepAnchor);
......
...@@ -1562,6 +1562,8 @@ void generateASTFwd_h(const Snapshot &snapshot, const QDir &cplusplusDir, const ...@@ -1562,6 +1562,8 @@ void generateASTFwd_h(const Snapshot &snapshot, const QDir &cplusplusDir, const
void generateASTPatternBuilder_h(const QDir &cplusplusDir) void generateASTPatternBuilder_h(const QDir &cplusplusDir)
{ {
typedef QPair<QString, QString> StringPair;
QFileInfo fileInfo(cplusplusDir, QLatin1String("ASTPatternBuilder.h")); QFileInfo fileInfo(cplusplusDir, QLatin1String("ASTPatternBuilder.h"));
QFile file(fileInfo.absoluteFilePath()); QFile file(fileInfo.absoluteFilePath());
if (! file.open(QFile::WriteOnly)) if (! file.open(QFile::WriteOnly))
...@@ -1619,7 +1621,7 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir) ...@@ -1619,7 +1621,7 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir)
out out
<< " " << className << " *" << methodName << "("; << " " << className << " *" << methodName << "(";
QList<QPair<QString, QString> > args; QList<StringPair> args;
bool first = true; bool first = true;
for (unsigned index = 0; index < klass->memberCount(); ++index) { for (unsigned index = 0; index < klass->memberCount(); ++index) {
...@@ -1652,8 +1654,7 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir) ...@@ -1652,8 +1654,7 @@ void generateASTPatternBuilder_h(const QDir &cplusplusDir)
<< " " << className << " *__ast = new (&pool) " << className << ';' << endl; << " " << className << " *__ast = new (&pool) " << className << ';' << endl;
QPair<QString, QString> p; foreach (const StringPair &p, args) {
foreach (p, args) {
out << " __ast->" << p.second << " = " << p.second << ';' << endl; out << " __ast->" << p.second << " = " << p.second << ';' << endl;
} }
......
...@@ -355,7 +355,7 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map, ...@@ -355,7 +355,7 @@ QVariantMap AddKitOperation::addKit(const QVariantMap &map,
// Sanity check: Make sure displayName is unique. // Sanity check: Make sure displayName is unique.
QStringList nameKeys = FindKeyOperation::findKey(map, QLatin1String(DISPLAYNAME)); QStringList nameKeys = FindKeyOperation::findKey(map, QLatin1String(DISPLAYNAME));
QStringList nameList; QStringList nameList;
foreach (const QString nameKey, nameKeys) foreach (const QString &nameKey, nameKeys)
nameList << GetOperation::get(map, nameKey).toString(); nameList << GetOperation::get(map, nameKey).toString();
const QString uniqueName = makeUnique(displayName, nameList); const QString uniqueName = makeUnique(displayName, nameList);
......
...@@ -285,7 +285,7 @@ QVariantMap AddQtOperation::addQt(const QVariantMap &map, ...@@ -285,7 +285,7 @@ QVariantMap AddQtOperation::addQt(const QVariantMap &map,
// Sanity check: Make sure displayName is unique. // Sanity check: Make sure displayName is unique.
QStringList nameKeys = FindKeyOperation::findKey(map, QLatin1String(DISPLAYNAME)); QStringList nameKeys = FindKeyOperation::findKey(map, QLatin1String(DISPLAYNAME));
QStringList nameList; QStringList nameList;
foreach (const QString nameKey, nameKeys) foreach (const QString &nameKey, nameKeys)
nameList << GetOperation::get(map, nameKey).toString(); nameList << GetOperation::get(map, nameKey).toString();
const QString uniqueName = makeUnique(displayName, nameList); const QString uniqueName = makeUnique(displayName, nameList);
......
...@@ -249,7 +249,7 @@ QVariantMap AddToolChainOperation::addToolChain(const QVariantMap &map, ...@@ -249,7 +249,7 @@ QVariantMap AddToolChainOperation::addToolChain(const QVariantMap &map,
// Sanity check: Make sure displayName is unique. // Sanity check: Make sure displayName is unique.
QStringList nameKeys = FindKeyOperation::findKey(map, QLatin1String(DISPLAYNAME)); QStringList nameKeys = FindKeyOperation::findKey(map, QLatin1String(DISPLAYNAME));
QStringList nameList; QStringList nameList;
foreach (const QString nameKey, nameKeys) foreach (const QString &nameKey, nameKeys)
nameList << GetOperation::get(map, nameKey).toString(); nameList << GetOperation::get(map, nameKey).toString();
const QString uniqueName = makeUnique(displayName, nameList); const QString uniqueName = makeUnique(displayName, nameList);
......
...@@ -74,7 +74,7 @@ int FindKeyOperation::execute() const ...@@ -74,7 +74,7 @@ int FindKeyOperation::execute() const
foreach (const QString &k, m_keys) { foreach (const QString &k, m_keys) {
const QStringList result = findKey(map, k); const QStringList result = findKey(map, k);
foreach (const QString r, result) foreach (const QString &r, result)
std::cout << qPrintable(r) << std::endl; std::cout << qPrintable(r) << std::endl;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment