From 9b187f8a3b9932ffd9c2909fe036638f3f575b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Thu, 2 Jun 2016 13:18:28 +0200 Subject: [PATCH] [libinput] Properly handle threaded Device creation Summary: Device is created from Connection::processEvents which is run in the main gui thread, while Connection itself is in a different thread. Thus passing *this* as parent is wrong. This change removes the parent, moves the created Device into the Connection thread and also deletes properly by using deleteLater. Reviewers: #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D1746 --- libinput/connection.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libinput/connection.cpp b/libinput/connection.cpp index 626b3cd9f0..c14b4066ee 100644 --- a/libinput/connection.cpp +++ b/libinput/connection.cpp @@ -214,7 +214,9 @@ void Connection::processEvents() QScopedPointer event(m_eventQueue.takeFirst()); switch (event->type()) { case LIBINPUT_EVENT_DEVICE_ADDED: { - auto device = new Device(event->nativeDevice(), this); + auto device = new Device(event->nativeDevice()); + device->moveToThread(s_thread); + device->setParent(this); m_devices << device; if (device->isKeyboard()) { m_keyboard++; @@ -278,7 +280,7 @@ void Connection::processEvents() emit hasTouchChanged(false); } } - delete device; + device->deleteLater(); break; } case LIBINPUT_EVENT_KEYBOARD_KEY: {