[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
This commit is contained in:
Martin Gräßlin 2016-06-02 13:18:28 +02:00
parent c04f193532
commit 9b187f8a3b

View file

@ -214,7 +214,9 @@ void Connection::processEvents()
QScopedPointer<Event> 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: {