diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-01-06 22:52:43 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-01-12 15:14:18 +0000 |
commit | 716c916c40b582c4fbeb34cd74301401d753ad0e (patch) | |
tree | 09bb07e26a522b028f97b4b14e167faa359e4ce6 /src | |
parent | b17c4d0e2e188c8e41afbccbc3ff4a96ec872e05 (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
Pick-to: 6.3
Change-Id: I580b6b225421a1e908f04c8e30adcdef6540ea52
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src')
-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 |