QWindowSystemInterface: use QBasicMutex and qt_scoped_lock
There's no reason to use a class-static mutex object here. Use a namespace-static QBasicMutex, port to qt_scoped_lock. Change-Id: Ia9bd3c2fadbf1da25ef79bb393c899b678cbc182 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
cf3d4cf3c3
commit
f2d752c59f
@ -46,7 +46,9 @@
|
|||||||
#include <qpa/qplatformintegration.h>
|
#include <qpa/qplatformintegration.h>
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include "qhighdpiscaling_p.h"
|
#include "qhighdpiscaling_p.h"
|
||||||
|
|
||||||
#include <QtCore/qscopedvaluerollback.h>
|
#include <QtCore/qscopedvaluerollback.h>
|
||||||
|
#include <QtCore/private/qlocking_p.h>
|
||||||
|
|
||||||
#if QT_CONFIG(draganddrop)
|
#if QT_CONFIG(draganddrop)
|
||||||
#include <qpa/qplatformdrag.h>
|
#include <qpa/qplatformdrag.h>
|
||||||
@ -623,7 +625,7 @@ bool QWindowSystemInterface::isTouchDeviceRegistered(const QTouchDevice *device)
|
|||||||
static int g_nextPointId = 1;
|
static int g_nextPointId = 1;
|
||||||
|
|
||||||
// map from device-independent point id (arbitrary) to "Qt point" ids
|
// map from device-independent point id (arbitrary) to "Qt point" ids
|
||||||
QMutex QWindowSystemInterfacePrivate::pointIdMapMutex;
|
static QBasicMutex pointIdMapMutex;
|
||||||
typedef QMap<quint64, int> PointIdMap;
|
typedef QMap<quint64, int> PointIdMap;
|
||||||
Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap)
|
Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap)
|
||||||
|
|
||||||
@ -641,7 +643,7 @@ Q_GLOBAL_STATIC(PointIdMap, g_pointIdMap)
|
|||||||
*/
|
*/
|
||||||
static int acquireCombinedPointId(quint8 deviceId, int pointId)
|
static int acquireCombinedPointId(quint8 deviceId, int pointId)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex);
|
const auto locker = qt_scoped_lock(pointIdMapMutex);
|
||||||
|
|
||||||
quint64 combinedId64 = (quint64(deviceId) << 32) + pointId;
|
quint64 combinedId64 = (quint64(deviceId) << 32) + pointId;
|
||||||
auto it = g_pointIdMap->constFind(combinedId64);
|
auto it = g_pointIdMap->constFind(combinedId64);
|
||||||
@ -702,7 +704,7 @@ QList<QTouchEvent::TouchPoint>
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (states == Qt::TouchPointReleased) {
|
if (states == Qt::TouchPointReleased) {
|
||||||
QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex);
|
const auto locker = qt_scoped_lock(pointIdMapMutex);
|
||||||
|
|
||||||
// All points on deviceId have been released.
|
// All points on deviceId have been released.
|
||||||
// Remove all points associated with that device from g_pointIdMap.
|
// Remove all points associated with that device from g_pointIdMap.
|
||||||
@ -723,7 +725,7 @@ QList<QTouchEvent::TouchPoint>
|
|||||||
|
|
||||||
void QWindowSystemInterfacePrivate::clearPointIdMap()
|
void QWindowSystemInterfacePrivate::clearPointIdMap()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&QWindowSystemInterfacePrivate::pointIdMapMutex);
|
const auto locker = qt_scoped_lock(pointIdMapMutex);
|
||||||
g_pointIdMap->clear();
|
g_pointIdMap->clear();
|
||||||
g_nextPointId = 1;
|
g_nextPointId = 1;
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,6 @@ public:
|
|||||||
|
|
||||||
static QWaitCondition eventsFlushed;
|
static QWaitCondition eventsFlushed;
|
||||||
static QMutex flushEventMutex;
|
static QMutex flushEventMutex;
|
||||||
static QMutex pointIdMapMutex;
|
|
||||||
static QAtomicInt eventAccepted;
|
static QAtomicInt eventAccepted;
|
||||||
|
|
||||||
static QList<QTouchEvent::TouchPoint>
|
static QList<QTouchEvent::TouchPoint>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user