summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2025-03-17 16:20:07 +0100
committerQt Cherry-pick Bot <[email protected]>2025-03-18 09:40:47 +0000
commit45a36b9f07b6ee6c7b9e7b0d34d500acf47b165c (patch)
treed62e46dbff1237e982923316b73728aadec15e5a
parentac52750a8cc407079c261241a057ba20be95e523 (diff)
QSqlQueryModel: restore RVO in data()
The return of a default-constructed QVariant 'v' from three branches invites NRVO, but most compilers won't let it kick in, because there are two return statements that don't return 'v'. Return an rvalue from each branch, so RVO is guaranteed (since C++17) to kick in. Amends the start of the public history. Picking back all the way, since it's risk-free. Pick-to: 6.5 5.15 Change-Id: I495885bee3ebba63c9e52640903c792011c1dee2 Reviewed-by: Christian Ehrlicher <[email protected]> (cherry picked from commit 26ba78900d6dae5be24b83004f0f91db74ac95e4) Reviewed-by: Qt Cherry-pick Bot <[email protected]> (cherry picked from commit 89bc556da09759933f4f0773a85bfd70ce6b3c5e)
-rw-r--r--src/sql/models/qsqlquerymodel.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/sql/models/qsqlquerymodel.cpp b/src/sql/models/qsqlquerymodel.cpp
index 1aae088c64a..f109f042f16 100644
--- a/src/sql/models/qsqlquerymodel.cpp
+++ b/src/sql/models/qsqlquerymodel.cpp
@@ -329,19 +329,18 @@ QVariant QSqlQueryModel::data(const QModelIndex &item, int role) const
if (!item.isValid())
return QVariant();
- QVariant v;
if (role & ~(Qt::DisplayRole | Qt::EditRole))
- return v;
+ return QVariant();
if (!d->rec.isGenerated(item.column()))
- return v;
+ return QVariant();
QModelIndex dItem = indexInQuery(item);
if (dItem.row() > d->bottom.row())
const_cast<QSqlQueryModelPrivate *>(d)->prefetch(dItem.row());
if (!d->query.seek(dItem.row())) {
d->error = d->query.lastError();
- return v;
+ return QVariant();
}
return d->query.value(dItem.column());