Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.2.0, 5.2.1
-
None
-
Windows, Mac, Linux
-
373d858812a84b48be482dd64ad9d248ab2d5b3c
Description
The QSqlTableModel::selectRow is supposed to refresh the row in the model if any column value in the record has changed in the underlying sqlite db (I am using sqlite, but the problem should be the same for other dbs). However, if the last column value is unchanged in the cache and the underlying db, then the row is not refreshed. Please see the logical error given below:
bool QSqlTableModel::selectRow(int row)
{
:
:
:
bool needsAddingToCache = !exists || d->cache.contains(row);
if (!needsAddingToCache) {
const QSqlRecord curValues = record(row);
needsAddingToCache = curValues.count() != newValues.count();
if (!needsAddingToCache) {
// Look for changed values. Primary key fields are customarily first
// and probably change less often than other fields, so start at the end.
for (int f = curValues.count() - 1; f >= 0; --f)
}
}
if (needsAddingToCache)
{ d->cache[row].refresh(exists, newValues); emit headerDataChanged(Qt::Vertical, row, row); emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1)); } return true;
}
As shown above the if statement at qsqltablemodel.cpp:451 in Qt 5.2.0 is missing a brace so the control breaks out after comparing only the last column and so if the last column is unchanged the row is never refreshed.
Attachments
For Gerrit Dashboard: QTBUG-38509 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
84134,1 | [QtSql][QSqlTableModel] fix failure to refresh in selectRow() | release | qt/qtbase | Status: MERGED | +2 | 0 |