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 <lars.knoll@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>bb10
parent
552fba2386
commit
ca22a02296
|
|
@ -195,7 +195,7 @@ void QTouchDevice::setName(const QString &name)
|
|||
d->name = name;
|
||||
}
|
||||
|
||||
typedef QList<QTouchDevice *> TouchDevices;
|
||||
typedef QList<const QTouchDevice *> TouchDevices;
|
||||
Q_GLOBAL_STATIC(TouchDevices, deviceList)
|
||||
static QBasicMutex devicesMutex;
|
||||
|
||||
|
|
@ -214,26 +214,22 @@ static void cleanupDevicesList()
|
|||
QList<const QTouchDevice *> QTouchDevice::devices()
|
||||
{
|
||||
QMutexLocker lock(&devicesMutex);
|
||||
QList<QTouchDevice *> *devList = deviceList();
|
||||
QList<const QTouchDevice *> 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())
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtGui/qtouchdevice.h>
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue