aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFabian Kosmale <fabian.kosmale@qt.io>2019-10-30 14:09:13 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2019-12-05 14:09:39 +0100
commitdb321e74413ac088edaa209a57ad5147175df041 (patch)
treecddf8d0c9c2c787e9715258ad38ad2cc8e9762a6 /src
parentcc66dd33cc44b5131c27d85daecf1b920f900f49 (diff)
QQuickItemView: Emit correct change signal on model reset
As the variable was manually set to -1 beforehand, we would never emit the change signal, leaving bindings stale. However, simply removing the assignment would lead to not triggering the signal when currentIndex was 0. So now we set it to -2, which cannot happen in any other place. Note that QTBUG-64998 was already mostly fixed due to earlier changes fixing the currentItem part, only currentIndex was still broken Fixes: QTBUG-68232 Fixes: QTBUG-64998 Fixes: QTBUG-63422 Change-Id: I885e06f1e258e67c3368d017bf79bff760440863 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/quick/items/qquickitemview.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index c58572de0f..66be3c79f8 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -235,7 +235,9 @@ void QQuickItemView::setModel(const QVariant &m)
if (isComponentComplete()) {
d->updateSectionCriteria();
d->refill();
- d->currentIndex = -1;
+ /* Setting currentIndex to -2 ensures that we always enter the "currentIndex changed"
+ code path in setCurrentIndex, updating bindings depending on currentIndex.*/
+ d->currentIndex = -2;
setCurrentIndex(d->model->count() > 0 ? 0 : -1);
d->updateViewport();