aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-01-26 16:44:55 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-02-08 08:01:34 +0000
commit6cfeabe92db25a10812a657f7f4fdadfb505204d (patch)
tree32956de018fa184a0547bc04593b750bc2ab55cf
parentce15c3af57858b9b8b0621398121691b20c6f638 (diff)
Flickable: handle child mouse ungrab when hidden or disabled
If Flickable got hidden while a child had mouse grab, it ignored the mouse ungrab event of the child mouse grabber, and got therefore stuck in pressed state. Consequently, item view transitions were not executed since the item view though it was being pressed. Task-number: QTBUG-58453 Change-Id: I76f9f3190c3a95a2fafdce036d69ea1dc8127434 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
-rw-r--r--src/quick/items/qquickflickable.cpp5
-rw-r--r--tests/auto/quick/qquickflickable/data/hide.qml13
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp20
3 files changed, 37 insertions, 1 deletions
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index 1e778306e0..537367b3a3 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -2307,8 +2307,11 @@ bool QQuickFlickable::filterMouseEvent(QQuickItem *receiver, QMouseEvent *event)
bool QQuickFlickable::childMouseEventFilter(QQuickItem *i, QEvent *e)
{
Q_D(QQuickFlickable);
- if (!isVisible() || !isEnabled() || !isInteractive())
+ if (!isVisible() || !isEnabled() || !isInteractive()) {
+ d->cancelInteraction();
return QQuickItem::childMouseEventFilter(i, e);
+ }
+
switch (e->type()) {
case QEvent::MouseButtonPress:
case QEvent::MouseMove:
diff --git a/tests/auto/quick/qquickflickable/data/hide.qml b/tests/auto/quick/qquickflickable/data/hide.qml
new file mode 100644
index 0000000000..ab520549e2
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/hide.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+Flickable {
+ id: flickable
+ width: 200; height: 200
+ contentWidth: 400; contentHeight: 400
+
+ MouseArea {
+ objectName: "mouseArea"
+ width: 400; height: 400
+ onDoubleClicked: flickable.visible = false
+ }
+}
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index 942e99018f..2555322e3e 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -80,6 +80,7 @@ private slots:
void disabled();
void flickVelocity();
void margins();
+ void cancelOnHide();
void cancelOnMouseGrab();
void clickAndDragWhenTransformed();
void flickTwiceUsingTouches();
@@ -1422,6 +1423,25 @@ void tst_qquickflickable::margins()
delete root;
}
+void tst_qquickflickable::cancelOnHide()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("hide.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+ QVERIFY(window->rootObject());
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable);
+
+ QTest::mouseDClick(window.data(), Qt::LeftButton);
+ QVERIFY(!flickable->isVisible());
+ QVERIFY(!QQuickFlickablePrivate::get(flickable)->pressed);
+}
+
void tst_qquickflickable::cancelOnMouseGrab()
{
QScopedPointer<QQuickView> window(new QQuickView);