backends/libinput: Destroy Connection in correct thread
This commit is contained in:
parent
7622921de6
commit
eea79bddd8
4 changed files with 11 additions and 9 deletions
|
@ -80,7 +80,7 @@ Q_SIGNALS:
|
||||||
void deviceRemoved(QString sysName);
|
void deviceRemoved(QString sysName);
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Connection> Connection::create(Session *session)
|
Connection *Connection::create(Session *session)
|
||||||
{
|
{
|
||||||
std::unique_ptr<Udev> udev = std::make_unique<Udev>();
|
std::unique_ptr<Udev> udev = std::make_unique<Udev>();
|
||||||
if (!udev->isValid()) {
|
if (!udev->isValid()) {
|
||||||
|
@ -96,7 +96,7 @@ std::unique_ptr<Connection> Connection::create(Session *session)
|
||||||
qCWarning(KWIN_LIBINPUT) << "Failed to initialize context";
|
qCWarning(KWIN_LIBINPUT) << "Failed to initialize context";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return std::unique_ptr<Connection>(new Connection(std::move(context)));
|
return new Connection(std::move(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection::Connection(std::unique_ptr<Context> &&input)
|
Connection::Connection(std::unique_ptr<Context> &&input)
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
QStringList devicesSysNames() const;
|
QStringList devicesSysNames() const;
|
||||||
|
|
||||||
static std::unique_ptr<Connection> create(Session *session);
|
static Connection *create(Session *session);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void deviceAdded(KWin::LibInput::Device *);
|
void deviceAdded(KWin::LibInput::Device *);
|
||||||
|
|
|
@ -21,21 +21,23 @@ LibinputBackend::LibinputBackend(Session *session, QObject *parent)
|
||||||
m_connection->moveToThread(&m_thread);
|
m_connection->moveToThread(&m_thread);
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
m_connection.get(), &LibInput::Connection::eventsRead, this, [this]() {
|
m_connection, &LibInput::Connection::eventsRead, this, [this]() {
|
||||||
m_connection->processEvents();
|
m_connection->processEvents();
|
||||||
},
|
},
|
||||||
Qt::QueuedConnection);
|
Qt::QueuedConnection);
|
||||||
|
|
||||||
// Direct connection because the deviceAdded() and the deviceRemoved() signals are emitted
|
// Direct connection because the deviceAdded() and the deviceRemoved() signals are emitted
|
||||||
// from the main thread.
|
// from the main thread.
|
||||||
connect(m_connection.get(), &LibInput::Connection::deviceAdded,
|
connect(m_connection, &LibInput::Connection::deviceAdded,
|
||||||
this, &InputBackend::deviceAdded, Qt::DirectConnection);
|
this, &InputBackend::deviceAdded, Qt::DirectConnection);
|
||||||
connect(m_connection.get(), &LibInput::Connection::deviceRemoved,
|
connect(m_connection, &LibInput::Connection::deviceRemoved,
|
||||||
this, &InputBackend::deviceRemoved, Qt::DirectConnection);
|
this, &InputBackend::deviceRemoved, Qt::DirectConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
LibinputBackend::~LibinputBackend()
|
LibinputBackend::~LibinputBackend()
|
||||||
{
|
{
|
||||||
|
m_connection->deleteLater();
|
||||||
|
|
||||||
m_thread.quit();
|
m_thread.quit();
|
||||||
m_thread.wait();
|
m_thread.wait();
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QThread m_thread;
|
QThread m_thread;
|
||||||
std::unique_ptr<LibInput::Connection> m_connection;
|
LibInput::Connection *m_connection = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace KWin
|
} // namespace KWin
|
||||||
|
|
Loading…
Reference in a new issue