aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2015-09-25 23:13:56 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2015-09-29 09:27:17 +0000
commit98637d8ba2bb40d5bfa0fa63dbc56541ac8ddd64 (patch)
treefea5f491469cad3e566e23cf6552bb00acb5e131
parent70c4a9ea2a8c3e5f6ac1ca714d096586adda0613 (diff)
Flickable: remove spurious emission of content size changes
If contentWidth or contentHeight is negative (unspecified), Flickable should not emit contentWidthChanged() or contentHeightChanged() when its own geometry changes. The value of contentWidth or contentHeight does not change. It remains negative (unspecified). Change-Id: Iad478d11e2e4370d2e94abe84cfd62d144e23dd9 Task-number: QTBUG-35038 Reviewed-by: Robin Burchell <robin.burchell@viroteck.net> Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r--src/quick/items/qquickflickable.cpp8
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp35
2 files changed, 37 insertions, 6 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index ea4398bc71..bef766a516 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -1640,10 +1640,8 @@ void QQuickFlickable::geometryChanged(const QRectF &newGeometry,
bool changed = false;
if (newGeometry.width() != oldGeometry.width()) {
changed = true; // we must update visualArea.widthRatio
- if (d->hData.viewSize < 0) {
+ if (d->hData.viewSize < 0)
d->contentItem->setWidth(width());
- emit contentWidthChanged();
- }
// Make sure that we're entirely in view.
if (!d->pressed && !d->hData.moving && !d->vData.moving) {
d->fixupMode = QQuickFlickablePrivate::Immediate;
@@ -1652,10 +1650,8 @@ void QQuickFlickable::geometryChanged(const QRectF &newGeometry,
}
if (newGeometry.height() != oldGeometry.height()) {
changed = true; // we must update visualArea.heightRatio
- if (d->vData.viewSize < 0) {
+ if (d->vData.viewSize < 0)
d->contentItem->setHeight(height());
- emit contentHeightChanged();
- }
// Make sure that we're entirely in view.
if (!d->pressed && !d->hData.moving && !d->vData.moving) {
d->fixupMode = QQuickFlickablePrivate::Immediate;
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index eee7ffe560..f7267800c9 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -93,6 +93,7 @@ private slots:
void pressDelayWithLoader();
void movementFromProgrammaticFlick();
void cleanup();
+ void contentSize();
private:
void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to);
@@ -1739,6 +1740,40 @@ void tst_qquickflickable::movementFromProgrammaticFlick()
QTRY_COMPARE(flickable->property("signalString").toString(), QString("msfsfeme"));
}
+// QTBUG_35038
+void tst_qquickflickable::contentSize()
+{
+ QQuickFlickable flickable;
+ QCOMPARE(flickable.contentWidth(), qreal(-1));
+ QCOMPARE(flickable.contentHeight(), qreal(-1));
+
+ QSignalSpy cwspy(&flickable, SIGNAL(contentWidthChanged()));
+ QVERIFY(cwspy.isValid());
+
+ QSignalSpy chspy(&flickable, SIGNAL(contentHeightChanged()));
+ QVERIFY(chspy.isValid());
+
+ flickable.setWidth(100);
+ QCOMPARE(flickable.width(), qreal(100));
+ QCOMPARE(flickable.contentWidth(), qreal(-1.0));
+ QCOMPARE(cwspy.count(), 0);
+
+ flickable.setContentWidth(10);
+ QCOMPARE(flickable.width(), qreal(100));
+ QCOMPARE(flickable.contentWidth(), qreal(10));
+ QCOMPARE(cwspy.count(), 1);
+
+ flickable.setHeight(100);
+ QCOMPARE(flickable.height(), qreal(100));
+ QCOMPARE(flickable.contentHeight(), qreal(-1.0));
+ QCOMPARE(chspy.count(), 0);
+
+ flickable.setContentHeight(10);
+ QCOMPARE(flickable.height(), qreal(100));
+ QCOMPARE(flickable.contentHeight(), qreal(10));
+ QCOMPARE(chspy.count(), 1);
+}
+
QTEST_MAIN(tst_qquickflickable)
#include "tst_qquickflickable.moc"