From 9ee53afb32cc1bea6f60f4ca7a951330a979c04a Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 23 Sep 2011 11:11:10 +0300 Subject: Avoid crash in handleTouchEvent and remove superfluous mapping. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 252d1b34b26779cbc1ac269f4af7fdb1f27038ef introduces a mapFromGlobal call in QWindowSystemInterface::handleTouchEvent. This has two issues: It ignores the fact that the tlw parameter can be null, resulting in an instant crash with the touch support of some platforms, and the mapping itself is unneccessary because QGuiApplication::processTouchEvent() will perform the same, the rect set via setRect() is basically ignored due to the touchPoint.d.rect = ... just before sending the final event to the widget in qguiapplication.cpp. Using setScreenRect instead of setRect is a valid fix from the previous patch, but the parts for the mapping need to be removed. Change-Id: I0bb40c7d647fb062106b151e5987f9970d6ab2c8 Reviewed-on: http://codereview.qt-project.org/5448 Reviewed-by: Qt Sanity Bot Reviewed-by: Bjørn Erik Nilsen --- src/gui/kernel/qwindowsysteminterface_qpa.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/gui/kernel/qwindowsysteminterface_qpa.cpp') diff --git a/src/gui/kernel/qwindowsysteminterface_qpa.cpp b/src/gui/kernel/qwindowsysteminterface_qpa.cpp index 898de3a425..bad1b86935 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa.cpp +++ b/src/gui/kernel/qwindowsysteminterface_qpa.cpp @@ -235,14 +235,8 @@ void QWindowSystemInterface::handleTouchEvent(QWindow *tlw, ulong timestamp, QEv p.setScreenPos(screenPos); p.setScreenRect(point->area); - // Map screen pos to local (QWindow) coordinates and preserve sub-pixel resolution. - const QPointF delta = screenPos - screenPos.toPoint(); - const QPointF localPos = tlw->mapFromGlobal(screenPos.toPoint()) + delta; - p.setPos(localPos); - - QRectF rect(0, 0, point->area.width(), point->area.height()); - rect.moveCenter(localPos); - p.setRect(rect); + // The local pos and rect are not set, they will be calculated + // when the event gets processed by QGuiApplication. p.setNormalizedPos(point->normalPosition); -- cgit v1.2.3