aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickevents.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-11-29 14:50:05 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2017-02-10 13:05:05 +0000
commit146c0bd566a0a1d4bd92619eefeae272d45a44bc (patch)
tree7d4e051d473cff2e90a3130b02b48faa69891ede /src/quick/items/qquickevents.cpp
parent50aaca40fe09a3ab6c927f7a550b2e97cf332a9c (diff)
add categorized log message in QQuickEventPoint::cancelPassiveGrab
and move some duplicated formatting code into helper functions Change-Id: If572278f0342f7476ee1ea32b0cfb51cf18f11da Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'src/quick/items/qquickevents.cpp')
-rw-r--r--src/quick/items/qquickevents.cpp44
1 files changed, 26 insertions, 18 deletions
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index eb4a6636f2..bd4e48fb05 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -467,6 +467,22 @@ Q_GLOBAL_STATIC_WITH_ARGS(ConstructableQQuickPointerDevice, g_genericMouseDevice
typedef QHash<qint64, QQuickPointerDevice *> PointerDeviceForDeviceIdHash;
Q_GLOBAL_STATIC(PointerDeviceForDeviceIdHash, g_tabletDevices)
+// debugging helpers
+static const char *pointStateString(const QQuickEventPoint *point)
+{
+ static const QMetaEnum stateMetaEnum = point->metaObject()->enumerator(point->metaObject()->indexOfEnumerator("State"));
+ return stateMetaEnum.valueToKey(point->state());
+}
+
+static const QString pointDeviceName(const QQuickEventPoint *point)
+{
+ auto device = static_cast<const QQuickPointerEvent *>(point->parent())->device();
+ QString deviceName = (device ? device->name() : QLatin1String("null device"));
+ deviceName.resize(16, ' '); // shorten, and align in case of sequential output
+ return deviceName;
+}
+
+
QQuickPointerDevice *QQuickPointerDevice::touchDevice(QTouchDevice *d)
{
if (g_touchDevices->contains(d))
@@ -572,11 +588,7 @@ void QQuickEventPoint::setGrabberItem(QQuickItem *grabber)
{
if (grabber != m_exclusiveGrabber.data()) {
if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
- auto device = static_cast<const QQuickPointerEvent *>(parent())->device();
- static const QMetaEnum stateMetaEnum = metaObject()->enumerator(metaObject()->indexOfEnumerator("State"));
- QString deviceName = (device ? device->name() : QLatin1String("null device"));
- deviceName.resize(16, ' '); // shorten, and align in case of sequential output
- qCDebug(lcPointerGrab) << deviceName << "point" << hex << m_pointId << stateMetaEnum.valueToKey(state())
+ qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this)
<< ": grab" << m_exclusiveGrabber << "->" << grabber;
}
m_exclusiveGrabber = QPointer<QObject>(grabber);
@@ -593,16 +605,12 @@ QQuickPointerHandler *QQuickEventPoint::grabberPointerHandler() const
void QQuickEventPoint::setGrabberPointerHandler(QQuickPointerHandler *grabber, bool exclusive)
{
if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
- auto device = static_cast<const QQuickPointerEvent *>(parent())->device();
- static const QMetaEnum stateMetaEnum = metaObject()->enumerator(metaObject()->indexOfEnumerator("State"));
- QString deviceName = (device ? device->name() : QLatin1String("null device"));
- deviceName.resize(16, ' '); // shorten, and align in case of sequential output
if (exclusive) {
if (m_exclusiveGrabber != grabber)
- qCDebug(lcPointerGrab) << deviceName << "point" << hex << m_pointId << stateMetaEnum.valueToKey(state())
+ qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this)
<< ": grab (exclusive)" << m_exclusiveGrabber << "->" << grabber;
} else {
- qCDebug(lcPointerGrab) << deviceName << "point" << hex << m_pointId << stateMetaEnum.valueToKey(state())
+ qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this)
<< ": grab (passive)" << grabber;
}
}
@@ -631,12 +639,7 @@ void QQuickEventPoint::cancelExclusiveGrab()
return;
}
if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
- // TODO somehow avoid duplicating this code from setGrabberPointerHandler
- auto device = static_cast<const QQuickPointerEvent *>(parent())->device();
- static const QMetaEnum stateMetaEnum = metaObject()->enumerator(metaObject()->indexOfEnumerator("State"));
- QString deviceName = (device ? device->name() : QLatin1String("null device"));
- deviceName.resize(16, ' '); // shorten, and align in case of sequential output
- qCDebug(lcPointerGrab) << deviceName << "point" << hex << m_pointId << stateMetaEnum.valueToKey(state())
+ qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this)
<< ": grab (exclusive)" << m_exclusiveGrabber << "-> nullptr";
}
if (auto handler = grabberPointerHandler())
@@ -646,8 +649,13 @@ void QQuickEventPoint::cancelExclusiveGrab()
void QQuickEventPoint::cancelPassiveGrab(QQuickPointerHandler *handler)
{
- if (m_passiveGrabbers.removeOne(QPointer<QQuickPointerHandler>(handler)))
+ if (m_passiveGrabbers.removeOne(QPointer<QQuickPointerHandler>(handler))) {
+ if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
+ qCDebug(lcPointerGrab) << pointDeviceName(this) << "point" << hex << m_pointId << pointStateString(this)
+ << ": grab (passive)" << handler << "removed";
+ }
handler->handleGrabCancel(this);
+ }
}
void QQuickEventPoint::cancelAllGrabs(QQuickPointerHandler *handler)