diff options
author | Mark Brand <mabrand@mabrand.nl> | 2013-01-30 00:39:53 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-06 07:57:28 +0100 |
commit | 33c212b7d25726b78c4bf630548a76feaab872f0 (patch) | |
tree | 33a9a44ae9f59e9444b321b97ddda7d1781df9a9 /src | |
parent | a694b9f8d204d6555caf4e30dbd18f536859c5bd (diff) |
QSqlTableModel::setData(): fix non-change detection
Commit 10ff9de91bedf93852f13a58287afd8831644759 introduced the
optimization of ignoring non-changes, but it overshot the mark.
It neglected to consider that QVariant's equality operator does not
compare the null flag. It also failed to consider that setData() has
a useful side effect of setting the generated flag in a column of a
pending INSERT. This is important when the application actually wants
a NULL to be inserted into the column.
Task-number: QTBUG-29217
Change-Id: I1368f7acc21eebfeb5a8d23746fc38f6f30fd395
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.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp index 32dd517a7a..a2a83e6a4b 100644 --- a/src/sql/models/qsqltablemodel.cpp +++ b/src/sql/models/qsqltablemodel.cpp @@ -587,7 +587,10 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in if (!(flags(index) & Qt::ItemIsEditable)) return false; - if (QSqlTableModel::data(index, role) == value) + const QVariant oldValue = QSqlTableModel::data(index, role); + if (value == oldValue + && value.isNull() == oldValue.isNull() + && d->cache.value(index.row()).op() != QSqlTableModelPrivate::Insert) return true; QSqlTableModelPrivate::ModifiedRow &row = d->cache[index.row()]; |