diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-01-06 22:52:43 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-13 14:17:50 +0000 |
commit | 9c438a066126b3c7a7ebffb81500767e2a4392ab (patch) | |
tree | 8ac84844a3772691d60fe4d8d92f2d305cb1b1b9 /src/gui/kernel | |
parent | 5674622b386f92a81cc36604e91eb2a33f98853a (diff) |
QSinglePointEvent: port away from QMutableEventPoint::from()
Use the new static QMutableEventPoint setters, which do not depend on
undefined behavior.
Made it a separate commit, because, while straight-forward, it's a lot
of changes compared to other users.
Task-number: QTBUG-99615
Change-Id: I580b6b225421a1e908f04c8e30adcdef6540ea52
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit 716c916c40b582c4fbeb34cd74301401d753ad0e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qevent.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index b5c57dbed8..af08d76e7a 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -550,30 +550,30 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d bool isWheel = (type == QEvent::Type::Wheel); auto devPriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(pointingDevice())); auto epd = devPriv->pointById(0); - QMutableEventPoint &mut = QMutableEventPoint::from(epd->eventPoint); - Q_ASSERT(mut.device() == dev); - // mut is now a reference to a non-detached instance that lives in QPointingDevicePrivate::activePoints. + QEventPoint &p = epd->eventPoint; + Q_ASSERT(p.device() == dev); + // p is a reference to a non-detached instance that lives in QPointingDevicePrivate::activePoints. // Update persistent info in that instance. if (isPress || isWheel) - mut.setGlobalLastPosition(globalPos); + QMutableEventPoint::setGlobalLastPosition(p, globalPos); else - mut.setGlobalLastPosition(mut.globalPosition()); - mut.setGlobalPosition(globalPos); - if (isWheel && mut.state() != QEventPoint::State::Updated) - mut.setGlobalPressPosition(globalPos); + QMutableEventPoint::setGlobalLastPosition(p, p.globalPosition()); + QMutableEventPoint::setGlobalPosition(p, globalPos); + if (isWheel && p.state() != QEventPoint::State::Updated) + QMutableEventPoint::setGlobalPressPosition(p, globalPos); if (type == MouseButtonDblClick) - mut.setState(QEventPoint::State::Stationary); + QMutableEventPoint::setState(p, QEventPoint::State::Stationary); else if (button == Qt::NoButton || isWheel) - mut.setState(QEventPoint::State::Updated); + QMutableEventPoint::setState(p, QEventPoint::State::Updated); else if (isPress) - mut.setState(QEventPoint::State::Pressed); + QMutableEventPoint::setState(p, QEventPoint::State::Pressed); else - mut.setState(QEventPoint::State::Released); - mut.setScenePosition(scenePos); + QMutableEventPoint::setState(p, QEventPoint::State::Released); + QMutableEventPoint::setScenePosition(p, scenePos); // Now detach, and update the detached instance with ephemeral state. - mut.detach(); - mut.setPosition(localPos); - m_points.append(mut); + QMutableEventPoint::detach(p); + QMutableEventPoint::setPosition(p, localPos); + m_points.append(p); } /*! \internal |