diff options
author | Maximilian Goldstein <max.goldstein@qt.io> | 2021-01-08 11:58:55 +0100 |
---|---|---|
committer | Maximilian Goldstein <max.goldstein@qt.io> | 2021-04-22 10:27:45 +0200 |
commit | 44055ebbe1db7e8f229de6c6936cd326b69dff15 (patch) | |
tree | d9f7289c6c0aec5d1682d549afc7ec79c34d13df /src/quick/items/qquickitemview.cpp | |
parent | 02f0c23d001b433e333ede211227c8021b55277e (diff) |
Fix warning and assert when removing items from groups
When removing items from groups actively shown by a model filter a warning
and assert was triggered in the past. This change fixes this behavior.
Fixes: QTBUG-86017
Change-Id: I49b7498a3d03141b654e453a3c35a43fc7ba804a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
(cherry picked from commit 8a3ede5ba1daf2d9314d71db972175b2791456c0)
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/quick/items/qquickitemview.cpp')
-rw-r--r-- | src/quick/items/qquickitemview.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp index 15cc6b34cf..3999109e47 100644 --- a/src/quick/items/qquickitemview.cpp +++ b/src/quick/items/qquickitemview.cpp @@ -2346,7 +2346,9 @@ FxViewItem *QQuickItemViewPrivate::createItem(int modelIndex, QQmlIncubator::Inc inRequest = true; - QObject* object = model->object(modelIndex, incubationMode); + // The model will run this same range check internally but produce a warning and return nullptr. + // Since we handle this result graciously in our code, we preempt this warning by checking the range ourselves. + QObject* object = modelIndex < model->count() ? model->object(modelIndex, incubationMode) : nullptr; QQuickItem *item = qmlobject_cast<QQuickItem*>(object); if (!item) { |