aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktumbler.cpp
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2017-07-03 13:14:57 +0200
committerMitch Curtis <mitch.curtis@qt.io>2017-07-07 09:16:26 +0000
commitcca6e8e3bd80824ff5aa3e17995a5b46ad48be28 (patch)
tree67664d7115c9c153700accab3972d70d44478efb /src/quicktemplates2/qquicktumbler.cpp
parent23482c09b812c0254ba5357e070441a6d847d7b2 (diff)
Tumbler: fix regression with currentIndex and currentItem
2c4b2d48 made Tumbler's wrap property follow its count by default, but did so using updatePolish() to account for the use case where a items are appended to the model in a for loop, as is done in TumblerDatePicker.qml in Tumbler's auto tests. This (appending items one at a time in a for loop) is not a good idea, but it should work. The problem with the solution is that the delay means that the use cases mentioned in the referenced bug report were broken. This patch removes the delay. The recursion guards are necessary due to the complex nature of TumblerView (and its non-standard use of the Qt Quick views), as they prevent a memory leak in QQuickListView::createHighlight() from being introuduced. We now call deleteLater() to ensure we do not interfere with the views' internal operations, and hence we also perform a few extra operations at the same time as insurance (although it appears that simply unparenting the internal view from QQuickTumblerView is enough to get the tests to pass). Task-number: QTBUG-61374 Change-Id: Ifef9e99522ea183b282ac862f346beaed12d0c09 Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktumbler.cpp')
-rw-r--r--src/quicktemplates2/qquicktumbler.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp
index 5cdd140d..80ab71ea 100644
--- a/src/quicktemplates2/qquicktumbler.cpp
+++ b/src/quicktemplates2/qquicktumbler.cpp
@@ -97,7 +97,8 @@ QQuickTumblerPrivate::QQuickTumblerPrivate()
currentIndex(-1),
pendingCurrentIndex(-1),
ignoreCurrentIndexChanges(false),
- count(0)
+ count(0),
+ ignoreSignals(false)
{
}
@@ -163,6 +164,9 @@ QQuickTumblerPrivate *QQuickTumblerPrivate::get(QQuickTumbler *tumbler)
void QQuickTumblerPrivate::_q_updateItemHeights()
{
+ if (ignoreSignals)
+ return;
+
// Can't use our own private padding members here, as the padding property might be set,
// which doesn't affect them, only their getters.
Q_Q(const QQuickTumbler);
@@ -174,6 +178,9 @@ void QQuickTumblerPrivate::_q_updateItemHeights()
void QQuickTumblerPrivate::_q_updateItemWidths()
{
+ if (ignoreSignals)
+ return;
+
Q_Q(const QQuickTumbler);
const qreal availableWidth = q->availableWidth();
const auto items = viewContentItemChildItems();
@@ -195,6 +202,8 @@ void QQuickTumblerPrivate::_q_onViewCurrentIndexChanged()
void QQuickTumblerPrivate::_q_onViewCountChanged()
{
Q_Q(QQuickTumbler);
+ if (ignoreSignals)
+ return;
setCount(view->property("count").toInt());
@@ -336,7 +345,9 @@ void QQuickTumbler::setCurrentIndex(int currentIndex)
couldSet = true;
} else {
d->ignoreCurrentIndexChanges = true;
+ d->ignoreSignals = true;
d->view->setProperty("currentIndex", currentIndex);
+ d->ignoreSignals = false;
d->ignoreCurrentIndexChanges = false;
couldSet = d->view->property("currentIndex").toInt() == currentIndex;