diff --git a/main_wayland.cpp b/main_wayland.cpp index 071a25fd55..f15601bad7 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -188,6 +188,15 @@ void ApplicationWayland::continueStartupWithX() environment.remove("DISPLAY"); environment.remove("WAYLAND_DISPLAY"); QProcess *p = new QProcess(this); + auto finishedSignal = static_cast(&QProcess::finished); + connect(p, finishedSignal, this, + [this, p] { + if (waylandServer()) { + waylandServer()->destroyInputMethodConnection(); + } + p->deleteLater(); + } + ); p->setProcessEnvironment(environment); p->start(m_inputMethodServerToStart); p->waitForStarted(); diff --git a/wayland_server.cpp b/wayland_server.cpp index aa2bf07b72..3bc4de3ffd 100644 --- a/wayland_server.cpp +++ b/wayland_server.cpp @@ -71,7 +71,10 @@ WaylandServer::WaylandServer(QObject *parent) qRegisterMetaType(); } -WaylandServer::~WaylandServer() = default; +WaylandServer::~WaylandServer() +{ + destroyInputMethodConnection(); +} void WaylandServer::destroyInternalConnection() { @@ -292,6 +295,15 @@ int WaylandServer::createInputMethodConnection() return sx[1]; } +void WaylandServer::destroyInputMethodConnection() +{ + if (!m_inputMethodServerConnection) { + return; + } + m_inputMethodServerConnection->destroy(); + m_inputMethodServerConnection = nullptr; +} + void WaylandServer::createInternalConnection() { int sx[2]; diff --git a/wayland_server.h b/wayland_server.h index 0dbe91dec6..64193d07d0 100644 --- a/wayland_server.h +++ b/wayland_server.h @@ -115,6 +115,7 @@ public: * @returns file descriptor to the input method server's socket. **/ int createInputMethodConnection(); + void destroyInputMethodConnection(); void createInternalConnection(); void destroyInternalConnection();