aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types/qqmllistmodelworkeragent_p.h
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/qml/types/qqmllistmodelworkeragent_p.h
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/qml/types/qqmllistmodelworkeragent_p.h')
-rw-r--r--src/qml/types/qqmllistmodelworkeragent_p.h27
1 files changed, 2 insertions, 25 deletions
diff --git a/src/qml/types/qqmllistmodelworkeragent_p.h b/src/qml/types/qqmllistmodelworkeragent_p.h
index 5a39651bf7..761a467e89 100644
--- a/src/qml/types/qqmllistmodelworkeragent_p.h
+++ b/src/qml/types/qqmllistmodelworkeragent_p.h
@@ -114,35 +114,12 @@ private:
friend class QQuickWorkerScriptEnginePrivate;
friend class QQmlListModel;
- struct Change
- {
- int modelUid;
- enum { Inserted, Removed, Moved, Changed } type;
- int index; // Inserted/Removed/Moved/Changed
- int count; // Inserted/Removed/Moved/Changed
- int to; // Moved
- QVector<int> roles;
- };
-
- struct Data
- {
- QList<Change> changes;
-
- void clearChange(int uid);
- void insertChange(int uid, int index, int count);
- void removeChange(int uid, int index, int count);
- void moveChange(int uid, int index, int count, int to);
- void changedChange(int uid, int index, int count, const QVector<int> &roles);
- };
- Data data;
-
struct Sync : public QEvent {
- Sync(const Data &d, QQmlListModel *l)
+ Sync(QQmlListModel *l)
: QEvent(QEvent::User)
- , data(d)
, list(l)
{}
- Data data;
+ ~Sync();
QQmlListModel *list;
};