diff options
-rw-r--r-- | src/gui/kernel/qgesturemanager.cpp | 6 | ||||
-rw-r--r-- | tests/auto/gestures/tst_gestures.cpp | 17 |
2 files changed, 14 insertions, 9 deletions
diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 000f44f..b0ef703 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -279,8 +279,10 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) QSet<QGesture *> notStarted = finishedGestures - activeGestures; if (!notStarted.isEmpty()) { // there are some gestures that claim to be finished, but never started. - qWarning("QGestureManager::filterEvent: some gestures were finished even though they've never started"); - finishedGestures -= notStarted; + // probably those are "singleshot" gestures so we'll fake the started state. + foreach (QGesture *gesture, notStarted) + gesture->d_func()->state = Qt::GestureStarted; + deliverEvents(notStarted, receiver); } activeGestures += startedGestures; diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 0a6caff..46ed45e 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -474,17 +474,20 @@ void tst_Gestures::finishedWithoutStarted() { GestureWidget widget; widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + // the gesture will claim it finished, but it was never started. CustomEvent ev; - QTest::ignoreMessage(QtWarningMsg, "QGestureManager::filterEvent: some gestures were finished even though they've never started"); - for (int i = CustomGesture::SerialFinishedThreshold; - i < CustomGesture::SerialFinishedThreshold+1; ++i) { - ev.serial = i; - QApplication::sendEvent(&widget, &ev); - } + ev.serial = CustomGesture::SerialFinishedThreshold; + QApplication::sendEvent(&widget, &ev); - QCOMPARE(widget.gestureEventsReceived, 0); + QCOMPARE(widget.customEventsReceived, 1); + QCOMPARE(widget.gestureEventsReceived, 2); QCOMPARE(widget.gestureOverrideEventsReceived, 0); + QCOMPARE(widget.events.all.size(), 2); + QCOMPARE(widget.events.started.size(), 1); + QCOMPARE(widget.events.updated.size(), 0); + QCOMPARE(widget.events.finished.size(), 1); + QCOMPARE(widget.events.canceled.size(), 0); } void tst_Gestures::unknownGesture() |