QSqlTableModel::insertRecord(): clean up after failed setRecord()

Change-Id: Ic9f314144bd3ccf4b59b9cb3f0d79f8d6f97a824
Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
This commit is contained in:
Mark Brand 2012-02-08 00:45:47 +01:00 committed by Qt by Nokia
parent 9c99f23ffb
commit 68cee5258b
2 changed files with 6 additions and 1 deletions

2
dist/changes-5.0.0 vendored
View File

@ -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 *

View File

@ -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;