aboutsummaryrefslogtreecommitdiffstats
path: root/src/imports
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-12-28 16:03:44 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-12-29 15:51:56 +0000
commit3accc1dae76575120e71cadb547e961ecd50bcb0 (patch)
tree2013ad02edb525ad22dac157e5a931b5cf162be5 /src/imports
parent1db9405128972d5ba77e33181bee40356f718cea (diff)
Fix failed assertions coming from the QML list model
QAbstractItemModel has become more strict in sanity checking the arguments of beginInsertRows and friends with change 00c09e752ff7e482e1308e0e34721dc979204595 in qtbase. Unfortunately, the QML list model was feeding it out of bound rows in some cases, leading to failed assertions. Fix this properly, by calculating the inserted/removed and changed rows on the fly when syncing the list model from the worker thread. Adjust the code in the XML list model as well, so it does call things in the proper order. Fix two tests, one for a minimal change in behavior (more correct now), the other to remove an assertion that is not valid anymore in debug builds (where assertions in QtCore will call rowCount()). Change-Id: Ied85269f78d41b64e06388590be3ed227ac88fdb Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/imports')
-rw-r--r--src/imports/xmllistmodel/qqmlxmllistmodel.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
index fc9f73a881..a013e8cf69 100644
--- a/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
+++ b/src/imports/xmllistmodel/qqmlxmllistmodel.cpp
@@ -1152,8 +1152,6 @@ void QQuickXmlListModel::queryCompleted(const QQuickXmlQueryResult &result)
int origCount = d->size;
bool sizeChanged = result.size != d->size;
- d->size = result.size;
- d->data = result.data;
d->keyRoleResultsCache = result.keyRoleResultsCache;
if (d->src.isEmpty() && d->xml.isEmpty())
d->status = Null;
@@ -1174,6 +1172,8 @@ void QQuickXmlListModel::queryCompleted(const QQuickXmlQueryResult &result)
beginRemoveRows(QModelIndex(), 0, origCount - 1);
endRemoveRows();
}
+ d->size = result.size;
+ d->data = result.data;
if (d->size > 0) {
beginInsertRows(QModelIndex(), 0, d->size - 1);
endInsertRows();
@@ -1187,6 +1187,8 @@ void QQuickXmlListModel::queryCompleted(const QQuickXmlQueryResult &result)
endRemoveRows();
}
}
+ d->size = result.size;
+ d->data = result.data;
for (int i=0; i<result.inserted.count(); i++) {
const int index = result.inserted[i].first;
const int count = result.inserted[i].second;