diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-09-14 13:47:14 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2017-09-14 11:54:45 +0000 |
commit | e29ffa179e9920443a23e2fcb3f0694df32e8a68 (patch) | |
tree | eb418119709f5f2e72a6331c310471cbc5828135 /src/qml/types/qqmllistmodel_p_p.h | |
parent | 3604cae410f29597c97ba73df6d31a9b54e6d30d (diff) |
Fix use-after-free when removing elements from a ListModel
Detaching delegate instances from model items is done after the
destruction of said model items. The problem is that after the model
item is destroyed, it will emit a change/destroyed signal. As the
delegate is still referencing the item, this will result in a
use-after-free. To provent that, the items are kept around until after
everyone (notably the delegate model) has been notified of the removal.
[ChangeLog][Qt][Qml] Fix possible use-after-free when removing items from a ListModel through JavaScript.
Task-number: QTBUG-59256
Change-Id: Iee182e2cf0b50d3dda2181fed95e38f1a60f22a9
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/types/qqmllistmodel_p_p.h')
-rw-r--r-- | src/qml/types/qqmllistmodel_p_p.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qml/types/qqmllistmodel_p_p.h b/src/qml/types/qqmllistmodel_p_p.h index cdce78e542..4928ad3725 100644 --- a/src/qml/types/qqmllistmodel_p_p.h +++ b/src/qml/types/qqmllistmodel_p_p.h @@ -367,7 +367,7 @@ public: void insert(int elementIndex, QV4::Object *object); void clear(); - void remove(int index, int count); + Q_REQUIRED_RESULT QVector<std::function<void()>> remove(int index, int count); int appendElement(); void insertElement(int index); |