Assert that QQmlDelegateModel's count can't be less than zero
I was running into a crash (it didn't reproduce with a minimal example, and I'm still not sure exactly what caused it) related to models and views, and saw that there m_count was negative, which shouldn't be possible. Adding this new assertion allowed me to find the issue in my code. Pick-to: 5.15 6.2 6.3 Change-Id: Ie467e749dbf95799618bd04591e50b0038cf3399 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
This commit is contained in:
parent
924b2d5d47
commit
d70b4ab2e5
|
@ -1746,6 +1746,7 @@ void QQmlDelegateModel::_q_itemsRemoved(int index, int count)
|
|||
return;
|
||||
|
||||
d->m_count -= count;
|
||||
Q_ASSERT(d->m_count >= 0);
|
||||
const QList<QQmlDelegateModelItem *> cache = d->m_cache;
|
||||
//Prevents items being deleted in remove loop
|
||||
for (QQmlDelegateModelItem *item : cache)
|
||||
|
|
Loading…
Reference in New Issue