From 46adeb79ec89ffccc5f090ebf17e2fe0bcedffef Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Mon, 25 Jan 2021 01:11:54 +0100 Subject: [PATCH] input methods: improve closing process Make sure it's destroyed when kwin shuts down, make sure we don't start it, for example because it crashed when we killed it like maliit does. --- main_wayland.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/main_wayland.cpp b/main_wayland.cpp index 4e157a0283..8e6434bbf5 100644 --- a/main_wayland.cpp +++ b/main_wayland.cpp @@ -119,7 +119,6 @@ ApplicationWayland::ApplicationWayland(int &argc, char **argv) connect(&m_inputMethodCrashTimer, &QTimer::timeout, this, [this] { m_inputMethodCrashes = 0; }); - connect(waylandServer(), &WaylandServer::terminatingInternalClientConnection, this, &ApplicationWayland::stopInputMethod); } ApplicationWayland::~ApplicationWayland() @@ -230,8 +229,13 @@ void ApplicationWayland::stopInputMethod() if (!m_inputMethodProcess) { return; } - m_inputMethodProcess->kill(); - m_inputMethodProcess->waitForFinished(); + disconnect(m_inputMethodProcess, nullptr, this, nullptr); + + m_inputMethodProcess->terminate(); + if (!m_inputMethodProcess->waitForFinished()) { + m_inputMethodProcess->kill(); + m_inputMethodProcess->waitForFinished(); + } if (waylandServer()) { waylandServer()->destroyInputMethodConnection(); } @@ -242,10 +246,12 @@ void ApplicationWayland::stopInputMethod() void ApplicationWayland::startInputMethod(const QString &executable) { stopInputMethod(); - if (executable.isEmpty()) { + if (executable.isEmpty() || isTerminating()) { return; } + connect(waylandServer(), &WaylandServer::terminatingInternalClientConnection, this, &ApplicationWayland::stopInputMethod, Qt::UniqueConnection); + QStringList arguments = KShell::splitArgs(executable); if (arguments.isEmpty()) { qWarning("Failed to launch the input method server: %s is an invalid command", qPrintable(m_inputMethodServerToStart));