QSqlTableModel::setData(): submit() instead of updateRowInTable()
authorMark Brand <mabrand@mabrand.nl>
Wed, 8 Feb 2012 08:38:05 +0000 (09:38 +0100)
committerQt by Nokia <qt-info@nokia.com>
Wed, 8 Feb 2012 13:43:18 +0000 (14:43 +0100)
Use submit() instead of calling updatRowInTable(). The effect is
exactly the same. Submit() invokes submitAll() which invokes
updateRowInTable(). The cache is purged and select() is called only
on success.

Change-Id: I3de9a3d6acf802ee6594d034a9e261e53637995d
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
src/sql/models/qsqltablemodel.cpp

index 38705c7..1746883 100644 (file)
@@ -508,17 +508,10 @@ bool QSqlTableModel::setData(const QModelIndex &index, const QVariant &value, in
     row.setValue(index.column(), value);
     emit dataChanged(index, index);
 
-    bool isOk = true;
-    if (d->strategy == OnFieldChange && row.op() != QSqlTableModelPrivate::Insert) {
-        // historical bug: bad style to call updateRowInTable.
-        // Should call submit(), but maybe the author wanted to avoid
-        // clearing the cache on failure.
-        isOk = updateRowInTable(index.row(), row.rec());
-        if (isOk)
-            select();
-    }
+    if (d->strategy == OnFieldChange && row.op() != QSqlTableModelPrivate::Insert)
+        return submit();
 
-    return isOk;
+    return true;
 }
 
 /*!