Fix warning: "Don't call QList::front() on temporary"

..using constFirst, instead.

[-Wclazy-detaching-temporary]

Change-Id: I66bd9c19d56dc5dcc7ee0a1f68f4bfd2a3af7326
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Alessandro Portale
2019-01-17 02:03:19 +01:00
parent adea8467f4
commit 5f5e82b0b6
3 changed files with 3 additions and 3 deletions

View File

@@ -347,7 +347,7 @@ void StackHandler::saveTaskFile()
while (!file.isOpen()) { while (!file.isOpen()) {
if (fileDialog.exec() != QDialog::Accepted) if (fileDialog.exec() != QDialog::Accepted)
return; return;
const QString fileName = fileDialog.selectedFiles().front(); const QString fileName = fileDialog.selectedFiles().constFirst();
file.setFileName(fileName); file.setFileName(fileName);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
QString msg = tr("Cannot open \"%1\": %2") QString msg = tr("Cannot open \"%1\": %2")

View File

@@ -115,7 +115,7 @@ void ItemLibraryResourceView::startDrag(Qt::DropActions /* supportedActions */)
auto fileSystemModel = qobject_cast<CustomFileSystemModel*>(model()); auto fileSystemModel = qobject_cast<CustomFileSystemModel*>(model());
Q_ASSERT(fileSystemModel); Q_ASSERT(fileSystemModel);
QFileInfo fileInfo = fileSystemModel->fileInfo(selectedIndexes().front()); QFileInfo fileInfo = fileSystemModel->fileInfo(selectedIndexes().constFirst());
QPixmap pixmap(fileInfo.absoluteFilePath()); QPixmap pixmap(fileInfo.absoluteFilePath());
if (!pixmap.isNull()) { if (!pixmap.isNull()) {
auto drag = new QDrag(this); auto drag = new QDrag(this);

View File

@@ -624,7 +624,7 @@ void VcsBaseSubmitEditor::slotInsertNickName()
void VcsBaseSubmitEditor::slotSetFieldNickName(int i) void VcsBaseSubmitEditor::slotSetFieldNickName(int i)
{ {
if (SubmitFieldWidget *sfw = d->m_widget->submitFieldWidgets().front()) { if (SubmitFieldWidget *sfw = d->m_widget->submitFieldWidgets().constFirst()) {
const QString nick = promptForNickName(); const QString nick = promptForNickName();
if (!nick.isEmpty()) if (!nick.isEmpty())
sfw->setFieldValue(i, nick); sfw->setFieldValue(i, nick);