From e3e0240c7798009d5cce9c4897b906fbce40dd24 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 21 Dec 2015 11:14:29 +0100 Subject: QGraphicsScene: prevent lots of detaching d/t editing of copies QTouchEvent::touchPoints() returns a const-&, but the old code took a copy, over which it then iterated, modifying the touch points, causing (necessary) detaches of both the list and the touch points. Befriend QTouchEvent and modify the list in-place, avoiding all detaches in the likely case that QTouchPoint contains the only copy of the touch point list. This is all the more important as the function is called once for every item-under-mouse in sendTouchBeginEvent(). Port to C++11 range-for as a drive-by. Change-Id: I2f74d19845711d97e3566886123b5d18d55db74c Reviewed-by: Andreas Aardal Hanssen --- src/gui/kernel/qevent.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/gui') diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 66e650c42d..cd65485397 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -908,6 +908,9 @@ protected: friend class QGuiApplicationPrivate; friend class QApplication; friend class QApplicationPrivate; +#ifndef QT_NO_GRAPHICSVIEW + friend class QGraphicsScenePrivate; // direct access to _touchPoints +#endif }; Q_DECLARE_TYPEINFO(QTouchEvent::TouchPoint, Q_MOVABLE_TYPE); Q_DECLARE_OPERATORS_FOR_FLAGS(QTouchEvent::TouchPoint::InfoFlags) -- cgit v1.2.3