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: {