summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-02-08 00:45:47 +0100
committerQt by Nokia <qt-info@nokia.com>2012-02-09 10:45:38 +0100
commit68cee5258b3db95aaf98c456a257863a2ef7ba14 (patch)
treed0c534ffa3de60a6256c89c66ab36b2a16ffd8d4
parent9c99f23ffb1666dae34f0a3aa0182f43de8e7d0c (diff)
QSqlTableModel::insertRecord(): clean up after failed setRecord()
Change-Id: Ic9f314144bd3ccf4b59b9cb3f0d79f8d6f97a824 Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
-rw-r--r--dist/changes-5.0.02
-rw-r--r--src/sql/models/qsqltablemodel.cpp5
2 files changed, 6 insertions, 1 deletions
diff --git a/dist/changes-5.0.0 b/dist/changes-5.0.0
index 996bdf4b0b..7726843ccb 100644
--- a/dist/changes-5.0.0
+++ b/dist/changes-5.0.0
@@ -355,6 +355,8 @@ ignore the rest of the range.
is consistent with the meaning of the flag.
-Require all fields to map correctly. Previously fields that didn't
map were simply ignored.
+ -For OnManualSubmit, insertRecord() no longer leaves behind an empty
+ row if setRecord() fails.
****************************************************************************
* Database Drivers *
diff --git a/src/sql/models/qsqltablemodel.cpp b/src/sql/models/qsqltablemodel.cpp
index 9e1cfe3051..35346c0f83 100644
--- a/src/sql/models/qsqltablemodel.cpp
+++ b/src/sql/models/qsqltablemodel.cpp
@@ -1079,8 +1079,11 @@ bool QSqlTableModel::insertRecord(int row, const QSqlRecord &record)
row = rowCount();
if (!insertRow(row, QModelIndex()))
return false;
- if (!setRecord(row, record))
+ if (!setRecord(row, record)) {
+ if (d->strategy == OnManualSubmit)
+ revertRow(row);
return false;
+ }
if (d->strategy == OnFieldChange || d->strategy == OnRowChange)
return submit();
return true;