Fix possible crash when removing items from QQmlDelegateModel
authorDaniel Vrátil <dvratil@kde.org>
Wed, 28 Jan 2015 18:09:04 +0000 (19:09 +0100)
committerDaniel Vrátil <dvratil@kde.org>
Mon, 2 Feb 2015 12:01:16 +0000 (12:01 +0000)
commit5df747fc5300f9c7e1da0fb86bab68209c921c9c
treed085a89d1f15a8805bfd2815b845487ef28aa70b
parent9230cb14ba383e0e2633725ade6a64f8b20bac41
Fix possible crash when removing items from QQmlDelegateModel

When iterating over the cache in QQmlDelegateModel::_q_itemsRemoved(), removing
of some of the items can trigger layout change in the view, which might in turn
remove a QQmlDelegateModelItem from the cache, causing us to dereference an
already deleted pointer.

To prevent crash, we always check whether the item is still valid in the original
cache and skip it if it has been removed in the meanwhile.

Task-number: QTBUG-34351
Change-Id: Ib91a0544e11dbd7bf6d82fa4dc4400cac9d0b5f7
Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
src/qml/types/qqmldelegatemodel.cpp