aboutsummaryrefslogtreecommitdiffstats
path: root/src/quickcontrols2
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2018-06-11 13:16:12 +0200
committerMitch Curtis <mitch.curtis@qt.io>2018-06-13 13:54:21 +0000
commit4624ec51b2f1672b109dfec536230f3920bdbd36 (patch)
tree98358369c2b2d6b03d209f6429b4a7d870be2a70 /src/quickcontrols2
parent8551dab69a0f4c8248c4eedd7ab650e15a8969f8 (diff)
Fix Tumbler not respecting currentIndex changes in onModelChanged
The use case in the referenced bug report looks something like this: Tumbler { model: 4 // ... onModelChanged: { currentIndex = model - 2; } } The problem was that setting currentIndex in onModelChanged would cause the wrap to change to true, which in turn caused the internal view to change to PathView. This would cause the currentIndex to be set to 0 on successive model changes (i.e ++model). By keeping track of whether or not the user set the currentIndex during a model change, we can ignore changes in the internal view's currentIndex and restore the user's currentIndex afterwards. Task-number: QTBUG-68737 Change-Id: I25738f36cf58a331d1b8e50b5029b4aa1dd27db5 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r--src/quickcontrols2/qquicktumblerview.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp
index 59d05211..a510a1fe 100644
--- a/src/quickcontrols2/qquicktumblerview.cpp
+++ b/src/quickcontrols2/qquicktumblerview.cpp
@@ -221,9 +221,9 @@ void QQuickTumblerView::updateModel()
// Since QQuickTumbler can't know about QQuickTumblerView, we use its private API to
// inform it that it should delay setting wrap.
QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(m_tumbler);
- tumblerPrivate->lockWrap();
+ tumblerPrivate->beginSetModel();
m_pathView->setModel(m_model);
- tumblerPrivate->unlockWrap();
+ tumblerPrivate->endSetModel();
// The count-depends-on-wrap behavior could cause wrap to change after
// the call above, so we must check that we're still using a PathView.
@@ -234,7 +234,7 @@ void QQuickTumblerView::updateModel()
QQuickTumblerPrivate *tumblerPrivate = QQuickTumblerPrivate::get(m_tumbler);
// setModel() causes QQuickTumblerPrivate::_q_onViewCountChanged() to
- // be called called, which calls QQuickTumbler::setCurrentIndex(),
+ // be called, which calls QQuickTumbler::setCurrentIndex(),
// which results in QQuickItemViewPrivate::createHighlightItem() being
// called. When the highlight item is created,
// QQuickTumblerPrivate::itemChildAdded() is notified and