diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2022-01-04 15:46:07 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-07 23:29:03 +0000 |
commit | 94481b4d45ef14f7ea8746b8252a9dbcdd743e97 (patch) | |
tree | aa6c2382624b1f77ee30b89e9c79f7800a6b7c2e | |
parent | e35b06219d5456c8ce7c96931f7c627a480c56db (diff) |
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.
Change-Id: Ie467e749dbf95799618bd04591e50b0038cf3399
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit d70b4ab2e58bcfd5e65c1d11a79020bb3e2906c0)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/qmlmodels/qqmldelegatemodel.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/qmlmodels/qqmldelegatemodel.cpp b/src/qmlmodels/qqmldelegatemodel.cpp index e76d9f4529..e58d4cc18e 100644 --- a/src/qmlmodels/qqmldelegatemodel.cpp +++ b/src/qmlmodels/qqmldelegatemodel.cpp @@ -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) |