From ca22a022967848358e1b2f0eec9588a0cb12a5e5 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 11 Jun 2015 21:03:04 +0200 Subject: [PATCH] QTouchDevicePrivate: deal in const QTouchDevice*s Avoids the copying of the contents when returning devices(). Remove an unneeded #include (already includes by public header; unneeded there, too, but leaving for SC purposes). Change-Id: Ifa9a3dc2c7fada01fb624527dd4d16d0cb32a658 Reviewed-by: Lars Knoll Reviewed-by: Friedemann Kleint --- src/gui/kernel/qtouchdevice.cpp | 14 +++++--------- src/gui/kernel/qtouchdevice_p.h | 5 ++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/gui/kernel/qtouchdevice.cpp b/src/gui/kernel/qtouchdevice.cpp index 1a6e9deba8..9d19fa4b92 100644 --- a/src/gui/kernel/qtouchdevice.cpp +++ b/src/gui/kernel/qtouchdevice.cpp @@ -195,7 +195,7 @@ void QTouchDevice::setName(const QString &name) d->name = name; } -typedef QList TouchDevices; +typedef QList TouchDevices; Q_GLOBAL_STATIC(TouchDevices, deviceList) static QBasicMutex devicesMutex; @@ -214,26 +214,22 @@ static void cleanupDevicesList() QList QTouchDevice::devices() { QMutexLocker lock(&devicesMutex); - QList *devList = deviceList(); - QList constDevList; - for (int i = 0, count = devList->count(); i != count; ++i) - constDevList.append(devList->at(i)); - return constDevList; + return *deviceList(); } /*! \internal */ -bool QTouchDevicePrivate::isRegistered(QTouchDevice *dev) +bool QTouchDevicePrivate::isRegistered(const QTouchDevice *dev) { - QMutexLocker lock(&devicesMutex); + QMutexLocker locker(&devicesMutex); return deviceList()->contains(dev); } /*! \internal */ -void QTouchDevicePrivate::registerDevice(QTouchDevice *dev) +void QTouchDevicePrivate::registerDevice(const QTouchDevice *dev) { QMutexLocker lock(&devicesMutex); if (deviceList()->isEmpty()) diff --git a/src/gui/kernel/qtouchdevice_p.h b/src/gui/kernel/qtouchdevice_p.h index 9c0bcf3414..4aff8f2f33 100644 --- a/src/gui/kernel/qtouchdevice_p.h +++ b/src/gui/kernel/qtouchdevice_p.h @@ -45,7 +45,6 @@ // We mean it. // -#include #include QT_BEGIN_NAMESPACE @@ -65,8 +64,8 @@ public: QString name; int maxTouchPoints; - static void registerDevice(QTouchDevice *dev); - static bool isRegistered(QTouchDevice *dev); + static void registerDevice(const QTouchDevice *dev); + static bool isRegistered(const QTouchDevice *dev); }; QT_END_NAMESPACE