summaryrefslogtreecommitdiffstats
path: root/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp')
-rw-r--r--src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
index f59d8d5e99..04d4ac777e 100644
--- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
+++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
@@ -46,6 +46,7 @@
#include <QtDeviceDiscoverySupport/private/qdevicediscovery_p.h>
#include <private/qguiapplication_p.h>
#include <private/qinputdevicemanager_p_p.h>
+#include <private/qmemory_p.h>
QT_BEGIN_NAMESPACE
@@ -99,17 +100,15 @@ QEvdevTouchManager::QEvdevTouchManager(const QString &key, const QString &specif
QEvdevTouchManager::~QEvdevTouchManager()
{
- qDeleteAll(m_activeDevices);
}
void QEvdevTouchManager::addDevice(const QString &deviceNode)
{
qCDebug(qLcEvdevTouch, "evdevtouch: Adding device at %ls", qUtf16Printable(deviceNode));
- QEvdevTouchScreenHandlerThread *handler;
- handler = new QEvdevTouchScreenHandlerThread(deviceNode, m_spec);
+ auto handler = qt_make_unique<QEvdevTouchScreenHandlerThread>(deviceNode, m_spec);
if (handler) {
- m_activeDevices.insert(deviceNode, handler);
- connect(handler, &QEvdevTouchScreenHandlerThread::touchDeviceRegistered, this, &QEvdevTouchManager::updateInputDeviceCount);
+ m_activeDevices.add(deviceNode, std::move(handler));
+ connect(handler.get(), &QEvdevTouchScreenHandlerThread::touchDeviceRegistered, this, &QEvdevTouchManager::updateInputDeviceCount);
} else {
qWarning("evdevtouch: Failed to open touch device %ls", qUtf16Printable(deviceNode));
}
@@ -117,12 +116,8 @@ void QEvdevTouchManager::addDevice(const QString &deviceNode)
void QEvdevTouchManager::removeDevice(const QString &deviceNode)
{
- if (m_activeDevices.contains(deviceNode)) {
+ if (m_activeDevices.remove(deviceNode)) {
qCDebug(qLcEvdevTouch, "evdevtouch: Removing device at %ls", qUtf16Printable(deviceNode));
- QEvdevTouchScreenHandlerThread *handler = m_activeDevices.value(deviceNode);
- m_activeDevices.remove(deviceNode);
- delete handler;
-
updateInputDeviceCount();
}
}
@@ -130,8 +125,8 @@ void QEvdevTouchManager::removeDevice(const QString &deviceNode)
void QEvdevTouchManager::updateInputDeviceCount()
{
int registeredTouchDevices = 0;
- Q_FOREACH (QEvdevTouchScreenHandlerThread *handler, m_activeDevices) {
- if (handler->isTouchDeviceRegistered())
+ for (const auto &device : m_activeDevices) {
+ if (device.handler->isTouchDeviceRegistered())
++registeredTouchDevices;
}