forked from qt-creator/qt-creator
Fix warnings about possible detach of temporary objects
Calling first() or last() on temporary container may unnecessarily detach the container. Fix it by calling constFirst() and constLast(). Change-Id: I2460efd5dbee1534eec8a514d9bff2a947bfddf9 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -424,7 +424,7 @@ namespace ADS
|
|||||||
if (areaWidget)
|
if (areaWidget)
|
||||||
return addDockWidget(ADS::CenterDockWidgetArea, dockWidget, areaWidget);
|
return addDockWidget(ADS::CenterDockWidgetArea, dockWidget, areaWidget);
|
||||||
else if (!openedDockAreas().isEmpty())
|
else if (!openedDockAreas().isEmpty())
|
||||||
return addDockWidget(area, dockWidget, openedDockAreas().last());
|
return addDockWidget(area, dockWidget, openedDockAreas().constLast());
|
||||||
else
|
else
|
||||||
return addDockWidget(area, dockWidget, nullptr);
|
return addDockWidget(area, dockWidget, nullptr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -327,7 +327,8 @@ void AndroidSettingsWidget::updateNdkList()
|
|||||||
|
|
||||||
void AndroidSettingsWidget::addCustomNdkItem()
|
void AndroidSettingsWidget::addCustomNdkItem()
|
||||||
{
|
{
|
||||||
const QString homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first();
|
const QString homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation)
|
||||||
|
.constFirst();
|
||||||
const QString ndkPath = QFileDialog::getExistingDirectory(this, tr("Select an NDK"), homePath);
|
const QString ndkPath = QFileDialog::getExistingDirectory(this, tr("Select an NDK"), homePath);
|
||||||
|
|
||||||
if (m_androidConfig.isValidNdk(ndkPath)) {
|
if (m_androidConfig.isValidNdk(ndkPath)) {
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ QString CppToolsJsExtension::includeStatement(
|
|||||||
{
|
{
|
||||||
if (fullyQualifiedClassName.isEmpty())
|
if (fullyQualifiedClassName.isEmpty())
|
||||||
return {};
|
return {};
|
||||||
const QString className = parts(fullyQualifiedClassName).last();
|
const QString className = parts(fullyQualifiedClassName).constLast();
|
||||||
if (className.isEmpty() || specialClasses.contains(className))
|
if (className.isEmpty() || specialClasses.contains(className))
|
||||||
return {};
|
return {};
|
||||||
if (className.startsWith('Q') && className.length() > 2 && className.at(1).isUpper())
|
if (className.startsWith('Q') && className.length() > 2 && className.at(1).isUpper())
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ void ConsoleView::onRowActivated(const QModelIndex &index)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const QFileInfo fi = m_finder.findFile(model()->data(index, ConsoleItem::FileRole).toString())
|
const QFileInfo fi = m_finder.findFile(model()->data(index, ConsoleItem::FileRole).toString())
|
||||||
.first().toFileInfo();
|
.constFirst().toFileInfo();
|
||||||
if (fi.exists() && fi.isFile() && fi.isReadable()) {
|
if (fi.exists() && fi.isFile() && fi.isReadable()) {
|
||||||
Core::EditorManager::openEditorAt(fi.canonicalFilePath(),
|
Core::EditorManager::openEditorAt(fi.canonicalFilePath(),
|
||||||
model()->data(index, ConsoleItem::LineRole).toInt());
|
model()->data(index, ConsoleItem::LineRole).toInt());
|
||||||
|
|||||||
@@ -2447,7 +2447,7 @@ QString QmlEngine::toFileInProject(const QUrl &fileUrl)
|
|||||||
d->fileFinder.setAdditionalSearchDirectories(rp.additionalSearchDirectories);
|
d->fileFinder.setAdditionalSearchDirectories(rp.additionalSearchDirectories);
|
||||||
d->fileFinder.setSysroot(rp.sysRoot);
|
d->fileFinder.setSysroot(rp.sysRoot);
|
||||||
|
|
||||||
return d->fileFinder.findFile(fileUrl).first().toString();
|
return d->fileFinder.findFile(fileUrl).constFirst().toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
DebuggerEngine *createQmlEngine()
|
DebuggerEngine *createQmlEngine()
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ static FilePath detectPython(const FilePath &documentPath)
|
|||||||
python = PythonSettings::defaultInterpreter().command;
|
python = PythonSettings::defaultInterpreter().command;
|
||||||
|
|
||||||
if (!python.exists() && !PythonSettings::interpreters().isEmpty())
|
if (!python.exists() && !PythonSettings::interpreters().isEmpty())
|
||||||
python = PythonSettings::interpreters().first().command;
|
python = PythonSettings::interpreters().constFirst().command;
|
||||||
|
|
||||||
return python;
|
return python;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
|||||||
|
|
||||||
// Register action as creator command to make it configurable
|
// Register action as creator command to make it configurable
|
||||||
Core::Command *command = Core::ActionManager::registerAction(
|
Core::Command *command = Core::ActionManager::registerAction(
|
||||||
action->action(), action->menuId().data(), context);
|
action->action(), action->menuId().constData(), context);
|
||||||
command->setDefaultKeySequence(action->action()->shortcut());
|
command->setDefaultKeySequence(action->action()->shortcut());
|
||||||
command->augmentActionWithShortcutToolTip(action->action());
|
command->augmentActionWithShortcutToolTip(action->action());
|
||||||
// Clear action shortcut so it doesn't conflict with command's override action
|
// Clear action shortcut so it doesn't conflict with command's override action
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ void RichTextEditor::setupHyperlinkActions()
|
|||||||
if (linkFormat.isAnchor()) {
|
if (linkFormat.isAnchor()) {
|
||||||
m_linkDialog->setLink(linkFormat.anchorHref());
|
m_linkDialog->setLink(linkFormat.anchorHref());
|
||||||
m_linkDialog->setAnchor(
|
m_linkDialog->setAnchor(
|
||||||
linkFormat.anchorNames().isEmpty() ? QString() : linkFormat.anchorNames().first());
|
linkFormat.anchorNames().isEmpty() ? QString() : linkFormat.anchorNames().constFirst());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_linkDialog->setLink("http://");
|
m_linkDialog->setLink("http://");
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ QPointF EasingCurve::start() const
|
|||||||
|
|
||||||
QPointF EasingCurve::end() const
|
QPointF EasingCurve::end() const
|
||||||
{
|
{
|
||||||
return toCubicSpline().last();
|
return toCubicSpline().constLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPainterPath EasingCurve::path() const
|
QPainterPath EasingCurve::path() const
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ QUrl QmlPreviewConnectionManager::findValidI18nDirectoryAsUrl(const QString &loc
|
|||||||
auto tryPath = [&](const QString &postfix) {
|
auto tryPath = [&](const QString &postfix) {
|
||||||
url.setPath(path + "/i18n/qml_" + postfix);
|
url.setPath(path + "/i18n/qml_" + postfix);
|
||||||
bool success = false;
|
bool success = false;
|
||||||
foundPath = m_projectFileFinder.findFile(url, &success).first().toString();
|
foundPath = m_projectFileFinder.findFile(url, &success).constFirst().toString();
|
||||||
foundPath = foundPath.left(qMax(0, foundPath.lastIndexOf("/i18n")));
|
foundPath = foundPath.left(qMax(0, foundPath.lastIndexOf("/i18n")));
|
||||||
return success;
|
return success;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ QString processArguments(QCoreApplication &application)
|
|||||||
if (parser.positionalArguments().isEmpty())
|
if (parser.positionalArguments().isEmpty())
|
||||||
parser.showHelp(1);
|
parser.showHelp(1);
|
||||||
|
|
||||||
return parser.positionalArguments().first();
|
return parser.positionalArguments().constFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|||||||
Reference in New Issue
Block a user