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.9 6.8 6.5 5.15 Change-Id: I495885bee3ebba63c9e52640903c792011c1dee2 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
parent
d038f3d692
commit
26ba78900d
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user