aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2019-01-17 01:54:13 +0100
committerAlessandro Portale <alessandro.portale@qt.io>2019-01-28 11:03:39 +0000
commitf5974ad993863290ff11407b6fbcd025e8e9b9ba (patch)
tree9904b2209196f9bfc69bb873a366fac9dc321734 /src
parent3fdb5f53e31f615836b8ed13cecb9527ba165e3c (diff)
Fix warning: "Don't call QVector::first() on temporary QList/QVector"
[-Wclazy-detaching-temporary] Change-Id: I23f5cbd80bb92d3f9f1bfb5ae07493818958c5b0 Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/libs/cplusplus/LookupContext.cpp2
-rw-r--r--src/libs/glsl/glslsemantic.cpp4
-rw-r--r--src/libs/utils/icon.cpp2
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp2
-rw-r--r--src/plugins/ios/iosconfigurations.cpp3
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp2
-rw-r--r--src/plugins/qmljseditor/qmljscompletionassist.cpp2
-rw-r--r--src/plugins/qmljstools/qmljsmodelmanager.cpp2
-rw-r--r--src/plugins/valgrind/callgrind/callgrinddatamodel.cpp2
-rw-r--r--src/plugins/valgrind/callgrindtool.cpp3
-rw-r--r--src/plugins/valgrind/memchecktool.cpp2
-rw-r--r--src/plugins/valgrind/suppressiondialog.cpp4
-rw-r--r--src/plugins/valgrind/xmlprotocol/errorlistmodel.cpp10
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.cpp2
-rw-r--r--src/shared/proparser/qmakeevaluator.cpp2
15 files changed, 23 insertions, 21 deletions
diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp
index 3f09e7b1a2d..026b293e2d4 100644
--- a/src/libs/cplusplus/LookupContext.cpp
+++ b/src/libs/cplusplus/LookupContext.cpp
@@ -799,7 +799,7 @@ void CreateBindings::lookupInScope(const Name *name, Scope *scope,
ClassOrNamespace *targetNamespaceBinding = binding->lookupType(name);
//there can be many namespace definitions
if (targetNamespaceBinding && targetNamespaceBinding->symbols().size() > 0) {
- Symbol *resolvedSymbol = targetNamespaceBinding->symbols().first();
+ Symbol *resolvedSymbol = targetNamespaceBinding->symbols().constFirst();
item.setType(resolvedSymbol->type()); // override the type
}
}
diff --git a/src/libs/glsl/glslsemantic.cpp b/src/libs/glsl/glslsemantic.cpp
index 9fe2c65732e..ae03ca148ab 100644
--- a/src/libs/glsl/glslsemantic.cpp
+++ b/src/libs/glsl/glslsemantic.cpp
@@ -393,9 +393,9 @@ bool Semantic::visit(FunctionCallExpressionAST *ast)
// ### error, unresolved call.
Q_ASSERT(! overloads->functions().isEmpty());
- _expr.type = overloads->functions().first()->returnType();
+ _expr.type = overloads->functions().constFirst()->returnType();
} else {
- _expr.type = candidates.first()->returnType();
+ _expr.type = candidates.constFirst()->returnType();
if (candidates.size() != 1) {
// ### error, ambiguous call
diff --git a/src/libs/utils/icon.cpp b/src/libs/utils/icon.cpp
index f7edbd8614b..ff5b5d12b47 100644
--- a/src/libs/utils/icon.cpp
+++ b/src/libs/utils/icon.cpp
@@ -239,7 +239,7 @@ QIcon Icon::modeIcon(const Icon &classic, const Icon &flat, const Icon &flatActi
QIcon Icon::combinedIcon(const QList<QIcon> &icons)
{
QIcon result;
- QWindow *window = QApplication::allWidgets().first()->windowHandle();
+ QWindow *window = QApplication::allWidgets().constFirst()->windowHandle();
for (const QIcon &icon: icons)
for (const QIcon::Mode mode: {QIcon::Disabled, QIcon::Normal})
for (const QSize &size: icon.availableSizes(mode))
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index 383b6a641ce..eeba204dbaf 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -2109,7 +2109,7 @@ public:
QString description;
if (m_change.operationList().size() == 1) {
description = QApplication::translate("CppTools::QuickFix",
- "Reformat to \"%1\"").arg(m_change.operationList().first().text);
+ "Reformat to \"%1\"").arg(m_change.operationList().constFirst().text);
} else { // > 1
description = QApplication::translate("CppTools::QuickFix",
"Reformat Pointers or References");
diff --git a/src/plugins/ios/iosconfigurations.cpp b/src/plugins/ios/iosconfigurations.cpp
index bbb85f022d2..d0b8b770f50 100644
--- a/src/plugins/ios/iosconfigurations.cpp
+++ b/src/plugins/ios/iosconfigurations.cpp
@@ -395,7 +395,8 @@ void IosConfigurations::load()
m_ignoreAllDevices = settings->value(ignoreAllDevicesKey, false).toBool();
m_screenshotDir = FileName::fromString(settings->value(screenshotDirPathKey).toString());
if (!m_screenshotDir.exists()) {
- QString defaultDir = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).first();
+ QString defaultDir =
+ QStandardPaths::standardLocations(QStandardPaths::PicturesLocation).constFirst();
m_screenshotDir = FileName::fromString(defaultDir);
}
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index 5cda7fc0b76..75882cff8c7 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -1919,7 +1919,7 @@ void ProjectExplorerPlugin::showOpenProjectError(const OpenProjectResult &result
QMessageBox::critical(ICore::mainWindow(), tr("Failed to Open Project"), errorMessage);
} else {
// ignore multiple alreadyOpen
- Project *alreadyOpen = result.alreadyOpen().first();
+ Project *alreadyOpen = result.alreadyOpen().constFirst();
ProjectTree::highlightProject(alreadyOpen,
tr("<h3>Project already open</h3>"));
}
diff --git a/src/plugins/qmljseditor/qmljscompletionassist.cpp b/src/plugins/qmljseditor/qmljscompletionassist.cpp
index 1d0393a950e..b307cb59ab5 100644
--- a/src/plugins/qmljseditor/qmljscompletionassist.cpp
+++ b/src/plugins/qmljseditor/qmljscompletionassist.cpp
@@ -788,7 +788,7 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
if (ScopeBuilder::isPropertyChangesObject(context, qmlScopeType)
&& scopeChain.qmlScopeObjects().size() == 2) {
CompletionAdder completionAdder(&m_completions, QmlJSCompletionAssistInterface::symbolIcon(), SymbolOrder);
- processProperties(scopeChain.qmlScopeObjects().first(), &completionAdder);
+ processProperties(scopeChain.qmlScopeObjects().constFirst(), &completionAdder);
}
}
diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp
index 53262a880a0..d328886f9e6 100644
--- a/src/plugins/qmljstools/qmljsmodelmanager.cpp
+++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp
@@ -253,7 +253,7 @@ ModelManagerInterface::WorkingCopy ModelManager::workingCopyInternal() const
const QString key = document->filePath().toString();
if (auto textDocument = qobject_cast<const TextEditor::TextDocument *>(document)) {
// TODO the language should be a property on the document, not the editor
- if (DocumentModel::editorsForDocument(document).first()
+ if (DocumentModel::editorsForDocument(document).constFirst()
->context().contains(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID)) {
workingCopy.insert(key, textDocument->plainText(),
textDocument->document()->revision());
diff --git a/src/plugins/valgrind/callgrind/callgrinddatamodel.cpp b/src/plugins/valgrind/callgrind/callgrinddatamodel.cpp
index 89a3e19387a..611c1634afb 100644
--- a/src/plugins/valgrind/callgrind/callgrinddatamodel.cpp
+++ b/src/plugins/valgrind/callgrind/callgrinddatamodel.cpp
@@ -233,7 +233,7 @@ QVariant DataModel::data(const QModelIndex &index, int role) const
ret += entry.arg(tr("Function:")).arg(func->name().toHtmlEscaped());
ret += entry.arg(tr("File:")).arg(func->file());
if (!func->costItems().isEmpty()) {
- const CostItem *firstItem = func->costItems().first();
+ const CostItem *firstItem = func->costItems().constFirst();
for (int i = 0; i < d->m_data->positions().size(); ++i) {
ret += entry.arg(ParseData::prettyStringForPosition(d->m_data->positions().at(i)))
.arg(firstItem->position(i));
diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp
index 0883e76cfc0..b9a83bc42ba 100644
--- a/src/plugins/valgrind/callgrindtool.cpp
+++ b/src/plugins/valgrind/callgrindtool.cpp
@@ -847,7 +847,8 @@ void CallgrindTool::showParserResults(const ParseData *data)
if (data->events().isEmpty()) {
msg = tr("Parsing finished, no data.");
} else {
- const QString costStr = QString::fromLatin1("%1 %2").arg(QString::number(data->totalCost(0)), data->events().first());
+ const QString costStr = QString::fromLatin1("%1 %2")
+ .arg(QString::number(data->totalCost(0)), data->events().constFirst());
msg = tr("Parsing finished, total cost of %1 reported.").arg(costStr);
}
} else {
diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp
index 2663d6a4f50..aaea6ba4d5a 100644
--- a/src/plugins/valgrind/memchecktool.cpp
+++ b/src/plugins/valgrind/memchecktool.cpp
@@ -355,7 +355,7 @@ bool MemcheckErrorFilterProxyModel::filterAcceptsRow(int sourceRow, const QModel
}
}
- const QVector< Frame > frames = error.stacks().first().frames();
+ const QVector<Frame> frames = error.stacks().constFirst().frames();
const int framesToLookAt = qMin(6, frames.size());
diff --git a/src/plugins/valgrind/suppressiondialog.cpp b/src/plugins/valgrind/suppressiondialog.cpp
index 52964d97cf4..67b5612b3e2 100644
--- a/src/plugins/valgrind/suppressiondialog.cpp
+++ b/src/plugins/valgrind/suppressiondialog.cpp
@@ -69,8 +69,8 @@ static QString suppressionText(const Error &error)
// try to set some useful name automatically, instead of "insert_name_here"
// we take the last stack frame and append the suppression kind, e.g.:
// QDebug::operator<<(bool) [Memcheck:Cond]
- if (!error.stacks().isEmpty() && !error.stacks().first().frames().isEmpty()) {
- const Frame frame = error.stacks().first().frames().first();
+ if (!error.stacks().isEmpty() && !error.stacks().constFirst().frames().isEmpty()) {
+ const Frame frame = error.stacks().constFirst().frames().constFirst();
QString newName;
if (!frame.functionName().isEmpty())
diff --git a/src/plugins/valgrind/xmlprotocol/errorlistmodel.cpp b/src/plugins/valgrind/xmlprotocol/errorlistmodel.cpp
index 98126f33a6e..85e5a68ac44 100644
--- a/src/plugins/valgrind/xmlprotocol/errorlistmodel.cpp
+++ b/src/plugins/valgrind/xmlprotocol/errorlistmodel.cpp
@@ -167,8 +167,8 @@ ErrorItem::ErrorItem(const ErrorListModel *model, const Error &error)
if (m_error.stacks().count() > 1) {
foreach (const Stack &s, m_error.stacks())
appendChild(new StackItem(s));
- } else if (m_error.stacks().first().frames().count() > 1) {
- foreach (const Frame &f, m_error.stacks().first().frames())
+ } else if (m_error.stacks().constFirst().frames().count() > 1) {
+ foreach (const Frame &f, m_error.stacks().constFirst().frames())
appendChild(new FrameItem(f));
}
}
@@ -211,12 +211,12 @@ QVariant ErrorItem::data(int column, int role) const
case Qt::DisplayRole:
// If and only if there is exactly one frame, we have omitted creating a child item for it
// (see the constructor) and display the function name in the error item instead.
- if (m_error.stacks().count() != 1 || m_error.stacks().first().frames().count() != 1
- || m_error.stacks().first().frames().first().functionName().isEmpty()) {
+ if (m_error.stacks().count() != 1 || m_error.stacks().constFirst().frames().count() != 1
+ || m_error.stacks().constFirst().frames().constFirst().functionName().isEmpty()) {
return m_error.what();
}
return ErrorListModel::tr("%1 in function %2")
- .arg(m_error.what(), m_error.stacks().first().frames().first().functionName());
+ .arg(m_error.what(), m_error.stacks().constFirst().frames().constFirst().functionName());
case Qt::ToolTipRole:
return toolTipForFrame(m_model->findRelevantFrame(m_error));
default:
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp
index 43f4256c936..bda0b6379b1 100644
--- a/src/plugins/vcsbase/vcsbaseclient.cpp
+++ b/src/plugins/vcsbase/vcsbaseclient.cpp
@@ -67,7 +67,7 @@ static Core::IEditor *locateEditor(const char *property, const QString &entry)
{
foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments())
if (document->property(property).toString() == entry)
- return Core::DocumentModel::editorsForDocument(document).first();
+ return Core::DocumentModel::editorsForDocument(document).constFirst();
return nullptr;
}
diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp
index 3ed649163d2..96fb672519c 100644
--- a/src/shared/proparser/qmakeevaluator.cpp
+++ b/src/shared/proparser/qmakeevaluator.cpp
@@ -941,7 +941,7 @@ QMakeEvaluator::VisitReturn QMakeEvaluator::visitProVariable(
m_dirSep = first(varName);
else if (varName == statics.strQMAKESPEC) {
if (!values(varName).isEmpty()) {
- QString spec = values(varName).first().toQString();
+ QString spec = values(varName).constFirst().toQString();
if (IoUtils::isAbsolutePath(spec)) {
m_qmakespec = spec;
m_qmakespecName = IoUtils::fileName(m_qmakespec).toString();