forked from qt-creator/qt-creator
Fix warning: "Don't call QVector::first() on temporary QList/QVector"
[-Wclazy-detaching-temporary] Change-Id: I23f5cbd80bb92d3f9f1bfb5ae07493818958c5b0 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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))
|
||||
|
@@ -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");
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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>"));
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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());
|
||||
|
@@ -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));
|
||||
|
@@ -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 {
|
||||
|
@@ -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());
|
||||
|
||||
|
@@ -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())
|
||||
|
@@ -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:
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user