From f672bff3383e3b6f555d0b7712d105003dea6525 Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Date: Mon, 1 Feb 2010 14:00:07 +0100
Subject: [PATCH] Fix some code scanning issues.

foreach()-Loops.
---
 src/libs/extensionsystem/plugindetailsview.cpp     |  8 ++++++--
 src/libs/utils/filesearch.cpp                      |  2 +-
 src/plugins/cmakeprojectmanager/cmakeproject.cpp   |  4 ++--
 .../coreplugin/editormanager/editormanager.cpp     |  2 +-
 .../coreplugin/editormanager/openeditorsmodel.cpp  |  4 ++--
 .../coreplugin/editormanager/openeditorswindow.cpp |  2 +-
 src/plugins/coreplugin/generalsettings.cpp         |  2 +-
 src/plugins/coreplugin/mimedatabase.cpp            |  4 ++--
 src/plugins/cpaster/pasteview.cpp                  |  2 +-
 src/plugins/cppeditor/cpphoverhandler.cpp          |  2 +-
 src/plugins/cpptools/cppcodecompletion.cpp         |  4 ++--
 src/plugins/cpptools/cppmodelmanager.cpp           |  2 +-
 src/plugins/debugger/debuggeroutputwindow.cpp      |  6 ++++--
 src/plugins/fakevim/fakevimhandler.cpp             |  2 +-
 src/plugins/help/filtersettingspage.cpp            | 10 +++++-----
 src/plugins/projectexplorer/buildstepspage.cpp     |  2 +-
 .../editorsettingspropertiespage.cpp               |  6 ++++--
 src/plugins/projectexplorer/persistentsettings.cpp |  2 +-
 src/plugins/qt4projectmanager/qt4project.cpp       |  4 ++--
 src/plugins/qt4projectmanager/qtversionmanager.cpp | 14 +++++++-------
 src/plugins/texteditor/basetexteditor.cpp          |  2 +-
 src/plugins/texteditor/codecselector.cpp           |  2 +-
 22 files changed, 48 insertions(+), 40 deletions(-)

diff --git a/src/libs/extensionsystem/plugindetailsview.cpp b/src/libs/extensionsystem/plugindetailsview.cpp
index 9d4f88489c4..ebd6e5f132f 100644
--- a/src/libs/extensionsystem/plugindetailsview.cpp
+++ b/src/libs/extensionsystem/plugindetailsview.cpp
@@ -83,8 +83,12 @@ void PluginDetailsView::update(PluginSpec *spec)
     m_ui->copyright->setText(spec->copyright());
     m_ui->license->setText(spec->license());
     QStringList depStrings;
-    foreach (PluginDependency dep, spec->dependencies()) {
-        depStrings << QString("%1 (%2)").arg(dep.name).arg(dep.version);
+    foreach (const PluginDependency &dep, spec->dependencies()) {
+        QString depString = dep.name;
+        depString += QLatin1String(" (");
+        depString += dep.version;
+        depString += QLatin1Char(')');
+        depStrings.append(depString);
     }
     m_ui->dependencies->addItems(depStrings);
 }
diff --git a/src/libs/utils/filesearch.cpp b/src/libs/utils/filesearch.cpp
index 192fa34321c..733d2039ceb 100644
--- a/src/libs/utils/filesearch.cpp
+++ b/src/libs/utils/filesearch.cpp
@@ -95,7 +95,7 @@ void runFileSearch(QFutureInterface<FileSearchResult> &future,
 
     QFile file;
     QBuffer buffer;
-    foreach (QString s, files) {
+    foreach (const QString &s, files) {
         if (future.isPaused())
             future.waitForResume();
         if (future.isCanceled()) {
diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
index 64176d6350b..e1b52d4b1bd 100644
--- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp
+++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp
@@ -180,7 +180,7 @@ bool CMakeProject::parseCMakeLists()
         QSet<QString> projectFiles;
         if (cbpparser.hasCMakeFiles()) {
             fileList.append(cbpparser.cmakeFileList());
-            foreach(ProjectExplorer::FileNode *node, cbpparser.cmakeFileList())
+            foreach(const ProjectExplorer::FileNode *node, cbpparser.cmakeFileList())
                 projectFiles.insert(node->path());
         } else {
             // Manually add the CMakeLists.txt file
@@ -219,7 +219,7 @@ bool CMakeProject::parseCMakeLists()
         QStringList allIncludePaths;
         QStringList allFrameworkPaths;
         QList<ProjectExplorer::HeaderPath> allHeaderPaths = activeBC->toolChain()->systemHeaderPaths();
-        foreach (ProjectExplorer::HeaderPath headerPath, allHeaderPaths) {
+        foreach (const ProjectExplorer::HeaderPath &headerPath, allHeaderPaths) {
             if (headerPath.kind() == ProjectExplorer::HeaderPath::FrameworkHeaderPath)
                 allFrameworkPaths.append(headerPath.path());
             else
diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp
index d732d6947f6..deb3c85b2f1 100644
--- a/src/plugins/coreplugin/editormanager/editormanager.cpp
+++ b/src/plugins/coreplugin/editormanager/editormanager.cpp
@@ -1550,7 +1550,7 @@ QByteArray EditorManager::saveState() const
     QList<OpenEditorsModel::Entry> entries = m_d->m_editorModel->entries();
     stream << entries.count();
 
-    foreach (OpenEditorsModel::Entry entry, entries) {
+    foreach (const OpenEditorsModel::Entry &entry, entries) {
         stream << entry.fileName() << entry.displayName() << entry.id().toUtf8();
     }
 
diff --git a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
index 3b0beefeda7..65c6f498787 100644
--- a/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorsmodel.cpp
@@ -67,7 +67,7 @@ int OpenEditorsModel::rowCount(const QModelIndex &parent) const
 QList<IEditor *> OpenEditorsModel::editors() const
 {
     QList<IEditor *> result;
-    foreach (Entry entry, m_editors)
+    foreach (const Entry &entry, m_editors)
         if (entry.editor)
             result += entry.editor;
     return result;
@@ -207,7 +207,7 @@ bool OpenEditorsModel::isDuplicate(IEditor *editor) const
 IEditor *OpenEditorsModel::originalForDuplicate(IEditor *duplicate) const
 {
     IFile *file = duplicate->file();
-    foreach(Entry e, m_editors)
+    foreach(const Entry &e, m_editors)
         if (e.editor && e.editor->file() == file)
             return e.editor;
     return 0;
diff --git a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
index 9c9bcb086c8..74cf587787d 100644
--- a/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
+++ b/src/plugins/coreplugin/editormanager/openeditorswindow.cpp
@@ -245,7 +245,7 @@ void OpenEditorsWindow::setEditors(EditorView *mainView, EditorView *view, OpenE
 }
 
     // add purely restored editors which are not initialised yet
-    foreach (OpenEditorsModel::Entry entry, model->entries()) {
+    foreach (const OpenEditorsModel::Entry &entry, model->entries()) {
         if (entry.editor)
             continue;
         QTreeWidgetItem *item = new QTreeWidgetItem();
diff --git a/src/plugins/coreplugin/generalsettings.cpp b/src/plugins/coreplugin/generalsettings.cpp
index a733a3b03df..7afec519d82 100644
--- a/src/plugins/coreplugin/generalsettings.cpp
+++ b/src/plugins/coreplugin/generalsettings.cpp
@@ -96,7 +96,7 @@ void GeneralSettings::fillLanguageBox() const
     const QStringList languageFiles = QDir(creatorTrPath).entryList(QStringList(QLatin1String("*.qm")));
     const QString currentLocale = language();
 
-    Q_FOREACH(const QString languageFile, languageFiles)
+    Q_FOREACH(const QString &languageFile, languageFiles)
     {
         int start = languageFile.lastIndexOf(QLatin1Char('_'))+1;
         int end = languageFile.lastIndexOf(QLatin1Char('.'));
diff --git a/src/plugins/coreplugin/mimedatabase.cpp b/src/plugins/coreplugin/mimedatabase.cpp
index b20dfecbf79..bc1dfcb3479 100644
--- a/src/plugins/coreplugin/mimedatabase.cpp
+++ b/src/plugins/coreplugin/mimedatabase.cpp
@@ -496,7 +496,7 @@ unsigned MimeType::matchesFile(const QFileInfo &file) const
 unsigned MimeType::matchesFile(Internal::FileMatchContext &c) const
 {
     // check globs
-    foreach (QRegExp pattern, m_d->globPatterns) {
+    foreach (const QRegExp &pattern, m_d->globPatterns) {
         if (pattern.exactMatch(c.fileName()))
             return GlobMatchPriority;
     }
@@ -507,7 +507,7 @@ unsigned MimeType::matchesFile(Internal::FileMatchContext &c) const
 
     const QByteArray data = c.data();
     if (!data.isEmpty()) {
-        foreach (MimeTypeData::IMagicMatcherSharedPointer matcher, m_d->magicMatchers) {
+        foreach (const MimeTypeData::IMagicMatcherSharedPointer &matcher, m_d->magicMatchers) {
             if (matcher->matches(data))
                 return matcher->priority();
         }
diff --git a/src/plugins/cpaster/pasteview.cpp b/src/plugins/cpaster/pasteview.cpp
index 21f00f151d3..679fdc96958 100644
--- a/src/plugins/cpaster/pasteview.cpp
+++ b/src/plugins/cpaster/pasteview.cpp
@@ -160,7 +160,7 @@ int PasteView::show(const QString &user, const QString &description, const QStri
     QByteArray content;
     m_parts = parts;
     m_ui.uiPatchList->clear();
-    foreach (const FileData part, parts) {
+    foreach (const FileData &part, parts) {
         QListWidgetItem *itm = new QListWidgetItem(part.filename, m_ui.uiPatchList);
         itm->setCheckState(Qt::Checked);
         itm->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
diff --git a/src/plugins/cppeditor/cpphoverhandler.cpp b/src/plugins/cppeditor/cpphoverhandler.cpp
index 71f5442a5b4..c1be3357ec0 100644
--- a/src/plugins/cppeditor/cpphoverhandler.cpp
+++ b/src/plugins/cppeditor/cpphoverhandler.cpp
@@ -289,7 +289,7 @@ void CppHoverHandler::updateHelpIdAndTooltip(TextEditor::ITextEditor *editor, in
     // We only want to show F1 if the tooltip matches the help id
     bool showF1 = true;
 
-    foreach (Document::DiagnosticMessage m, doc->diagnosticMessages()) {
+    foreach (const Document::DiagnosticMessage &m, doc->diagnosticMessages()) {
         if (m.line() == lineNumber) {
             m_toolTip = m.text();
             showF1 = false;
diff --git a/src/plugins/cpptools/cppcodecompletion.cpp b/src/plugins/cpptools/cppcodecompletion.cpp
index 87bc14ff494..3d7cbebf9d9 100644
--- a/src/plugins/cpptools/cppcodecompletion.cpp
+++ b/src/plugins/cpptools/cppcodecompletion.cpp
@@ -1178,7 +1178,7 @@ bool CppCodeCompletion::completeScope(const QList<LookupItem> &results,
 {
     QList<Symbol *> classes, namespaces;
 
-    foreach (LookupItem result, results) {
+    foreach (const LookupItem &result, results) {
         FullySpecifiedType ty = result.type();
 
         if (Class *classTy = ty->asClassType())
@@ -1489,7 +1489,7 @@ void CppCodeCompletion::completions(QList<TextEditor::CompletionItem> *completio
         } else if (m_completionOperator == T_LPAREN ||
                    m_completionOperator == T_SIGNAL ||
                    m_completionOperator == T_SLOT) {
-            foreach (TextEditor::CompletionItem item, m_completions) {
+            foreach (const TextEditor::CompletionItem &item, m_completions) {
                 if (item.text.startsWith(key, Qt::CaseInsensitive)) {
                     completions->append(item);
                 }
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index dd346e9cb79..5e691d5efd7 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -847,7 +847,7 @@ QFuture<void> CppModelManager::refreshSourceFiles(const QStringList &sourceFiles
 
             m_synchronizer.clearFutures();
 
-            foreach (QFuture<void> future, futures) {
+            foreach (const QFuture<void> &future, futures) {
                 if (! (future.isFinished() || future.isCanceled()))
                     m_synchronizer.addFuture(future);
             }
diff --git a/src/plugins/debugger/debuggeroutputwindow.cpp b/src/plugins/debugger/debuggeroutputwindow.cpp
index ca90c72ada3..4a84cd2b149 100644
--- a/src/plugins/debugger/debuggeroutputwindow.cpp
+++ b/src/plugins/debugger/debuggeroutputwindow.cpp
@@ -349,8 +349,10 @@ void DebuggerOutputWindow::showOutput(int channel, const QString &output)
     foreach (QString line, output.split('\n')) {
         // FIXME: QTextEdit asserts on really long lines...
         const int n = 30000;
-        if (line.size() > n)
-            line = line.left(n) + " [...] <cut off>";
+        if (line.size() > n) {
+            line.truncate(n);
+            line += QLatin1String(" [...] <cut off>");
+        }
         if (line != QLatin1String("(gdb) "))
             m_combinedText->appendPlainText(charForChannel(channel) + line);
     }
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp
index 6c6a0ecfb70..df9cfee2183 100644
--- a/src/plugins/fakevim/fakevimhandler.cpp
+++ b/src/plugins/fakevim/fakevimhandler.cpp
@@ -247,7 +247,7 @@ struct Range
 
 QDebug &operator<<(QDebug &ts, const QList<QTextEdit::ExtraSelection> &sels)
 {
-    foreach (QTextEdit::ExtraSelection sel, sels)
+    foreach (const QTextEdit::ExtraSelection &sel, sels)
         ts << "SEL: " << sel.cursor.anchor() << sel.cursor.position();
     return ts;
 }
diff --git a/src/plugins/help/filtersettingspage.cpp b/src/plugins/help/filtersettingspage.cpp
index fef6ad7acd7..3f2518665d3 100644
--- a/src/plugins/help/filtersettingspage.cpp
+++ b/src/plugins/help/filtersettingspage.cpp
@@ -99,8 +99,8 @@ void FilterSettingsPage::updateFilterPage()
     help.setupData();
     m_filterMapBackup.clear();
     const QStringList filters = help.customFilters();
-    foreach (const QString filter, filters) {
-        QStringList atts = help.filterAttributes(filter);
+    foreach (const QString &filter, filters) {
+        const QStringList atts = help.filterAttributes(filter);
         m_filterMapBackup.insert(filter, atts);
         if (!m_filterMap.contains(filter))
             m_filterMap.insert(filter, atts);
@@ -108,8 +108,8 @@ void FilterSettingsPage::updateFilterPage()
 
     m_ui.filterWidget->addItems(m_filterMap.keys());
 
-    foreach (const QString a, help.filterAttributes())
-        new QTreeWidgetItem(m_ui.attributeWidget, QStringList() << a);
+    foreach (const QString &a, help.filterAttributes())
+        new QTreeWidgetItem(m_ui.attributeWidget, QStringList(a));
 
     if (m_filterMap.keys().count())
         m_ui.filterWidget->setCurrentRow(0);
@@ -215,7 +215,7 @@ bool FilterSettingsPage::applyChanges()
         }
     }
     if (changed) {
-        foreach (QString filter, m_removedFilters)
+        foreach (const QString &filter, m_removedFilters)
             m_helpEngine->removeCustomFilter(filter);
         QMapIterator<QString, QStringList> it(m_filterMap);
         while (it.hasNext()) {
diff --git a/src/plugins/projectexplorer/buildstepspage.cpp b/src/plugins/projectexplorer/buildstepspage.cpp
index 4833254e303..d7fd91775a5 100644
--- a/src/plugins/projectexplorer/buildstepspage.cpp
+++ b/src/plugins/projectexplorer/buildstepspage.cpp
@@ -57,7 +57,7 @@ BuildStepsPage::BuildStepsPage(Project *project, bool clean) :
 
 BuildStepsPage::~BuildStepsPage()
 {
-    foreach(BuildStepsWidgetStruct s, m_buildSteps) {
+    foreach(const BuildStepsWidgetStruct &s, m_buildSteps) {
         delete s.widget;
         delete s.detailsWidget;
     }
diff --git a/src/plugins/projectexplorer/editorsettingspropertiespage.cpp b/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
index 6810920b556..be37cc9ea20 100644
--- a/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
+++ b/src/plugins/projectexplorer/editorsettingspropertiespage.cpp
@@ -99,8 +99,10 @@ EditorSettingsWidget::EditorSettingsWidget(Project *project)
         QTextCodec *codec = QTextCodec::codecForMib(mib);
         m_codecs += codec;
         QString name = codec->name();
-        foreach (QByteArray alias, codec->aliases())
-            name += QString(QLatin1String(" / ") + alias);
+        foreach (const QByteArray &alias, codec->aliases()) {
+            name += QLatin1String(" / ");
+            name += QString::fromLatin1(alias);
+        }
         m_ui.encodingComboBox->addItem(name);
         if (defaultTextCodec == codec)
             m_ui.encodingComboBox->setCurrentIndex(i);
diff --git a/src/plugins/projectexplorer/persistentsettings.cpp b/src/plugins/projectexplorer/persistentsettings.cpp
index 9b940959350..d06af8d0923 100644
--- a/src/plugins/projectexplorer/persistentsettings.cpp
+++ b/src/plugins/projectexplorer/persistentsettings.cpp
@@ -143,7 +143,7 @@ void PersistentSettingsWriter::writeValue(QDomElement &ps, const QVariant &varia
         QDomElement values = ps.ownerDocument().createElement("valuelist");
         values.setAttribute("type", QVariant::typeToName(QVariant::List));
         QList<QVariant> varList = variant.toList();
-        foreach (QVariant var, varList) {
+        foreach (const QVariant &var, varList) {
             writeValue(values, var);
         }
         ps.appendChild(values);
diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp
index e1e664999de..eb9699ff410 100644
--- a/src/plugins/qt4projectmanager/qt4project.cpp
+++ b/src/plugins/qt4projectmanager/qt4project.cpp
@@ -477,7 +477,7 @@ void Qt4Project::updateCodeModel()
         //foreach(const HeaderPath &hp, tc->systemHeaderPaths())
         //    qDebug()<<hp.path();
     }
-    foreach (HeaderPath headerPath, allHeaderPaths) {
+    foreach (const HeaderPath &headerPath, allHeaderPaths) {
         if (headerPath.kind() == HeaderPath::FrameworkHeaderPath)
             predefinedFrameworkPaths.append(headerPath.path());
         else
@@ -531,7 +531,7 @@ void Qt4Project::updateCodeModel()
         allPrecompileHeaders.append(info.precompiledHeader);
 
         // Add custom defines
-        foreach (const QString def, pro->variableValue(DefinesVar)) {
+        foreach (const QString &def, pro->variableValue(DefinesVar)) {
             definedMacros += "#define ";
             info.defines += "#define ";
             const int index = def.indexOf(QLatin1Char('='));
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 8ac704e5dbd..2cb443efb0d 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -327,7 +327,7 @@ void QtVersionManager::addNewVersionsFromInstaller()
 
     QStringList newVersionsList = newVersionsValue.split(';', QString::SkipEmptyParts);
     bool defaultVersionWasReset = false;
-    foreach (QString newVersion, newVersionsList) {
+    foreach (const QString &newVersion, newVersionsList) {
         QStringList newVersionData = newVersion.split('=');
         if (newVersionData.count() >= 2) {
             if (QFile::exists(newVersionData[1])) {
@@ -750,7 +750,7 @@ QtVersion *QtVersionManager::qtVersionForQMakeBinary(const QString &qmakePath)
 
 void dumpQMakeAssignments(const QList<QMakeAssignment> &list)
 {
-    foreach(QMakeAssignment qa, list) {
+    foreach(const QMakeAssignment &qa, list) {
         qDebug()<<qa.variable<<qa.op<<qa.value;
     }
 }
@@ -789,11 +789,11 @@ QPair<QtVersion::QmakeBuildConfigs, QStringList> QtVersionManager::scanMakeFile(
         dumpQMakeAssignments(assignments);
 
         result2.append(additionalArguments);
-        foreach(QMakeAssignment qa, assignments)
+        foreach(const QMakeAssignment &qa, assignments)
             result2.append(qa.variable + qa.op + qa.value);
         if (!afterAssignments.isEmpty()) {
             result2.append("-after");
-            foreach(QMakeAssignment qa, afterAssignments)
+            foreach(const QMakeAssignment &qa, afterAssignments)
                 result2.append(qa.variable + qa.op + qa.value);
         }
     }
@@ -918,7 +918,7 @@ QtVersion::QmakeBuildConfigs QtVersionManager::qmakeBuildConfigFromCmdArgs(QList
     QtVersion::QmakeBuildConfigs result = defaultBuildConfig;
     QList<QMakeAssignment> oldAssignments = *assignments;
     assignments->clear();
-    foreach(QMakeAssignment qa, oldAssignments) {
+    foreach(const QMakeAssignment &qa, oldAssignments) {
         if (qa.variable == "CONFIG") {
             QStringList values = qa.value.split(' ');
             QStringList newValues;
@@ -1100,7 +1100,7 @@ QList<QSharedPointer<ProjectExplorer::ToolChain> > QtVersion::toolChains() const
 
 ProjectExplorer::ToolChain *QtVersion::toolChain(ProjectExplorer::ToolChain::ToolChainType type) const
 {
-    foreach(QSharedPointer<ProjectExplorer::ToolChain> tcptr, toolChains())
+    foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tcptr, toolChains())
         if (tcptr->type() == type)
             return tcptr.data();
     return 0;
@@ -1109,7 +1109,7 @@ ProjectExplorer::ToolChain *QtVersion::toolChain(ProjectExplorer::ToolChain::Too
 QList<ProjectExplorer::ToolChain::ToolChainType> QtVersion::possibleToolChainTypes() const
 {
     QList<ProjectExplorer::ToolChain::ToolChainType> types;
-    foreach(QSharedPointer<ProjectExplorer::ToolChain> tc, toolChains())
+    foreach(const QSharedPointer<ProjectExplorer::ToolChain> &tc, toolChains())
         types << tc->type();
     return types;
 }
diff --git a/src/plugins/texteditor/basetexteditor.cpp b/src/plugins/texteditor/basetexteditor.cpp
index d0436d4eea8..0bbd9287507 100644
--- a/src/plugins/texteditor/basetexteditor.cpp
+++ b/src/plugins/texteditor/basetexteditor.cpp
@@ -4689,7 +4689,7 @@ void BaseTextEditor::_q_matchParentheses()
 
 
     if (animatePosition >= 0) {
-        foreach (QTextEdit::ExtraSelection sel, BaseTextEditor::extraSelections(ParenthesesMatchingSelection)) {
+        foreach (const QTextEdit::ExtraSelection &sel, BaseTextEditor::extraSelections(ParenthesesMatchingSelection)) {
             if (sel.cursor.selectionStart() == animatePosition
                 || sel.cursor.selectionEnd() - 1 == animatePosition) {
                 animatePosition = -1;
diff --git a/src/plugins/texteditor/codecselector.cpp b/src/plugins/texteditor/codecselector.cpp
index de5fc1343ac..c49bdc48b37 100644
--- a/src/plugins/texteditor/codecselector.cpp
+++ b/src/plugins/texteditor/codecselector.cpp
@@ -105,7 +105,7 @@ CodecSelector::CodecSelector(QWidget *parent, BaseTextDocument *doc)
                 continue;
         }
         QString names = QString::fromLatin1(c->name());
-        foreach (QByteArray alias, c->aliases())
+        foreach (const QByteArray &alias, c->aliases())
             names += QLatin1String(" / ") + QString::fromLatin1(alias);
         if (doc->codec() == c)
             currentIndex = encodings.count();
-- 
GitLab