summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-09-14 19:11:05 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-09-14 19:11:05 (GMT)
commit2a1c4cbca0db45fa911b6d4e9a5ae553f8289353 (patch)
tree2336957d7c13821745c5e3215b0c322bbeed8ddd
parent30b415bf8644961d3e5b108b0b7c1b1abf07f685 (diff)
parent33f9950996ada06fc39b68f6656b1defdccd8c3a (diff)
downloadQt-2a1c4cbca0db45fa911b6d4e9a5ae553f8289353.zip
Qt-2a1c4cbca0db45fa911b6d4e9a5ae553f8289353.tar.gz
Qt-2a1c4cbca0db45fa911b6d4e9a5ae553f8289353.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-1: fix QTBUG-13501 - crash when a gesture is accepted but not consumed Add test: assert when gesture is never accepted.
-rw-r--r--src/gui/kernel/qapplication.cpp6
-rw-r--r--tests/auto/gestures/tst_gestures.cpp26
2 files changed, 30 insertions, 2 deletions
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index caeeeb9..2fd2f46 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -4367,11 +4367,13 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
eventAccepted = ge.isAccepted();
for (int i = 0; i < gestures.size(); ++i) {
QGesture *g = gestures.at(i);
- if ((res && eventAccepted) || (!eventAccepted && ge.isAccepted(g))) {
+ // Ignore res [event return value] because handling of multiple gestures
+ // packed into a single QEvent depends on not consuming the event
+ if (eventAccepted || ge.isAccepted(g)) {
// if the gesture was accepted, mark the target widget for it
gestureEvent->d_func()->targetWidgets[g->gestureType()] = w;
gestureEvent->setAccepted(g, true);
- } else if (!eventAccepted && !ge.isAccepted(g)) {
+ } else {
// if the gesture was explicitly ignored by the application,
// put it back so a parent can get it
allGestures.append(g);
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index ddc3939..667cdd3 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
+#include <QtTest/qtesttouch.h>
#include "../../shared/util.h"
#include <qevent.h>
@@ -361,6 +362,7 @@ private slots:
void partialGesturePropagation();
void testQGestureRecognizerCleanup();
void testReuseCanceledGestures();
+ void bug_13501_gesture_not_accepted();
};
tst_Gestures::tst_Gestures()
@@ -2306,5 +2308,29 @@ void tst_Gestures::conflictingGesturesInGraphicsView()
QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
}
+class NoConsumeWidgetBug13501 :public QWidget
+{
+ Q_OBJECT
+protected:
+ bool event(QEvent *e) {
+ if(e->type() == QEvent::Gesture) {
+ return false;
+ }
+ return QWidget::event(e);
+ }
+};
+
+void tst_Gestures::bug_13501_gesture_not_accepted()
+{
+ // Create a gesture event that is not accepted by any widget
+ // make sure this does not lead to an assert in QGestureManager
+ NoConsumeWidgetBug13501 w;
+ w.grabGesture(Qt::TapGesture);
+ w.show();
+ QTest::qWaitForWindowShown(&w);
+ //QTest::mousePress(&ignoreEvent, Qt::LeftButton);
+ QTest::touchEvent(&w).press(0, QPoint(10, 10), &w);
+}
+
QTEST_MAIN(tst_Gestures)
#include "tst_gestures.moc"