QPointingDevPriv::setExclusiveGrabber: emit grabChanged with point found

...not with the given point.  Since QEventPoint has a constructor that
takes an id, it's possible to write something like
 pointerEvent->setExclusiveGrabber(pointId, object)
which will construct a QEventPoint on-the-fly, containing only an id.
(That was unintentional, but perhaps useful sometimes.)
setExclusiveGrabber() looks up the persistent point, but if we emit the
signal with the given point, it is missing the device.  A handler
connected to that signal might reasonably assume that the point is a
complete instance; so we'd better emit the complete instance that we
found.  (OTOH if the given point was a detached instance, it might also
be unexpected that the signal emits the persistent instance instead of
the given instance.)  Amends 2692237bb1

Change-Id: Iee16363dcb22c1dc07b0cc0a81930218e22fa19e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
bb10
Shawn Rutledge 2020-09-16 16:37:25 +02:00
parent 8932e80d0c
commit b850322147
1 changed files with 1 additions and 1 deletions

View File

@ -475,7 +475,7 @@ void QPointingDevicePrivate::setExclusiveGrabber(const QPointerEvent *event, con
auto oldGrabber = persistentPoint->exclusiveGrabber;
persistentPoint->exclusiveGrabber = exclusiveGrabber;
if (oldGrabber)
emit q->grabChanged(oldGrabber, QPointingDevice::UngrabExclusive, event, point);
emit q->grabChanged(oldGrabber, QPointingDevice::UngrabExclusive, event, persistentPoint->eventPoint);
if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
qCDebug(lcPointerGrab) << name << "point" << point.id() << point.state()
<< "@" << point.scenePosition()