summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-09-17 14:23:17 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-09-24 21:27:51 +0200
commit3c2733e45f7ce0ce9a626d1347bb83ddc41013b2 (patch)
tree6e763d1ae064596774ab37359b7a40de1b042019 /src
parent7389c096379d63d956a023835646af1179ac6ea4 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/sql/models/qsqltablemodel.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index fbd9207741..f442039d08 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -431,13 +431,15 @@ 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))
- return false;
+ {
+ QSqlQuery q(d->db);
+ q.setForwardOnly(true);
+ if (!q.exec(stmt))
+ return false;
- bool exists = q.next();
- d->cache[row].refresh(exists, q.record());
+ 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));