[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:
parent
c04f193532
commit
9b187f8a3b
1 changed files with 4 additions and 2 deletions
|
@ -214,7 +214,9 @@ void Connection::processEvents()
|
||||||
QScopedPointer<Event> event(m_eventQueue.takeFirst());
|
QScopedPointer<Event> event(m_eventQueue.takeFirst());
|
||||||
switch (event->type()) {
|
switch (event->type()) {
|
||||||
case LIBINPUT_EVENT_DEVICE_ADDED: {
|
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;
|
m_devices << device;
|
||||||
if (device->isKeyboard()) {
|
if (device->isKeyboard()) {
|
||||||
m_keyboard++;
|
m_keyboard++;
|
||||||
|
@ -278,7 +280,7 @@ void Connection::processEvents()
|
||||||
emit hasTouchChanged(false);
|
emit hasTouchChanged(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete device;
|
device->deleteLater();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LIBINPUT_EVENT_KEYBOARD_KEY: {
|
case LIBINPUT_EVENT_KEYBOARD_KEY: {
|
||||||
|
|
Loading…
Reference in a new issue