summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent_p.h
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-11-16 14:57:20 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-11-17 06:21:05 +0100
commit76dc75c5ff32f61782a413df4915f4ebe9236d76 (patch)
tree2391cf4ed4f17aaf4116f5e771c4f74065112970 /src/gui/kernel/qevent_p.h
parent496c977b43b131c6bf315cc030c21023b60e2661 (diff)
Allow QMutableSinglePointEvent to be copy- and default-constructed
Since QMutableSinglePointEvent is just an access-helper to QSinglePointEvent, we can safely create one from the other. This covers QMouseEvent as well with the right casting in place. And by making QMSPE default constructable, we can use it in code that needs to frequently copy event data, for example in QtQuick. This allows us to make the copy c'tor and assignment operators for QEvent classes protected, which prevents potentially dangerous (ie. slicing) implicit copies. Change-Id: I815774847cca63896f46c43df683053b3d952b61 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/gui/kernel/qevent_p.h')
-rw-r--r--src/gui/kernel/qevent_p.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 7c9974db7f..a776b957a5 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -84,7 +84,8 @@ static_assert(sizeof(QMutableTouchEvent) == sizeof(QTouchEvent));
class Q_GUI_EXPORT QMutableSinglePointEvent : public QSinglePointEvent
{
public:
- QMutableSinglePointEvent(Type type, const QPointingDevice *device, const QEventPoint &point,
+ QMutableSinglePointEvent(const QSinglePointEvent &other) : QSinglePointEvent(other) {}
+ QMutableSinglePointEvent(Type type = QEvent::None, const QPointingDevice *device = nullptr, const QEventPoint &point = QEventPoint(),
Qt::MouseButton button = Qt::NoButton, Qt::MouseButtons buttons = Qt::NoButton,
Qt::KeyboardModifiers modifiers = Qt::NoModifier,
Qt::MouseEventSource source = Qt::MouseEventSynthesizedByQt) :