From e55c2744cd13b00d2ca379b34e167ca381b2e7d7 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Wed, 27 Oct 2021 23:39:36 +0100 Subject: [PATCH] Disconnect watcher for xdgActivationTokenArrived XdgActivationTokens are loaded async. To acheive a job like pattern we were comparing serials in our slot when one was created. On wayland this isn't ideal because we're slowly building up an increasibly long list of lambdas being run, but they'll all no-op. On X11 because lastInputSerial is always 0 we run the slot multiple times for every system tray item each time an item is clicked or an application is launched. For xembedsniproxy this is especially problematic problematic as we will trigger synthesised input events in our slot. BUG: 444385 --- applets/systemtray/statusnotifieritemjob.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/applets/systemtray/statusnotifieritemjob.cpp b/applets/systemtray/statusnotifieritemjob.cpp index 01b74d7c3..2fa613827 100644 --- a/applets/systemtray/statusnotifieritemjob.cpp +++ b/applets/systemtray/statusnotifieritemjob.cpp @@ -7,6 +7,7 @@ #include "statusnotifieritemjob.h" #include +#include StatusNotifierItemJob::StatusNotifierItemJob(StatusNotifierItemSource *source, const QString &operation, QMap ¶meters, QObject *parent) : ServiceJob(source->objectName(), operation, parameters, parent) @@ -30,8 +31,10 @@ void StatusNotifierItemJob::start() QWindow *window = nullptr; const quint32 launchedSerial = KWindowSystem::lastInputSerial(window); - connect(KWindowSystem::self(), &KWindowSystem::xdgActivationTokenArrived, this, [this, launchedSerial](quint32 serial, const QString &token) { + auto conn = QSharedPointer::create(); + *conn = connect(KWindowSystem::self(), &KWindowSystem::xdgActivationTokenArrived, this, [this, launchedSerial, conn](quint32 serial, const QString &token) { if (serial == launchedSerial) { + disconnect(*conn); m_source->provideXdgActivationToken(token); performJob(); }