QEvdevTouchScreenData: use a mutex locker instead of manual lock/unlock()

Extra difficulty: the lock is conditional. Not a problem with std::unique_lock, which is movable.

Change-Id: Ib5515838ccb10100d5aa31163ab7f171591c04c4
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
This commit is contained in:
Marc Mutz 2019-05-19 23:04:02 +02:00
parent 9d0649d338
commit f7ae47ad07

View File

@ -49,6 +49,9 @@
#include <QtCore/private/qcore_unix_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <mutex>
#ifdef Q_OS_FREEBSD
#include <dev/evdev/input.h>
#else
@ -560,8 +563,9 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data)
if (!m_contacts.isEmpty() && m_contacts.constBegin().value().trackingId == -1)
assignIds();
std::unique_lock<QMutex> locker;
if (m_filtered)
m_mutex.lock();
locker = std::unique_lock<QMutex>{m_mutex};
// update timestamps
m_lastTimeStamp = m_timeStamp;
@ -648,9 +652,6 @@ void QEvdevTouchScreenData::processInputEvent(input_event *data)
if (!m_touchPoints.isEmpty() && combinedStates != Qt::TouchPointStationary)
reportPoints();
if (m_filtered)
m_mutex.unlock();
}
m_lastEventType = data->type;