QSqlTableModel::selectRow(): reduce scope of QSqlQuery
It's good to clean up the query before emitting signals about the updated row. It's possible that connected slots will call selectRow() again for other rows. Change-Id: I482fe2dd58218f53567ce8725ee591ce2eeda348 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Mark Brand <mabrand@mabrand.nl>
This commit is contained in:
parent
7389c09637
commit
3c2733e45f
@ -431,6 +431,7 @@ bool QSqlTableModel::selectRow(int row)
|
||||
d->sortColumn = table_sort_col;
|
||||
d->filter = table_filter;
|
||||
|
||||
{
|
||||
QSqlQuery q(d->db);
|
||||
q.setForwardOnly(true);
|
||||
if (!q.exec(stmt))
|
||||
@ -438,6 +439,7 @@ bool QSqlTableModel::selectRow(int row)
|
||||
|
||||
bool exists = q.next();
|
||||
d->cache[row].refresh(exists, q.record());
|
||||
}
|
||||
|
||||
emit headerDataChanged(Qt::Vertical, row, row);
|
||||
emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
|
||||
|
Loading…
Reference in New Issue
Block a user