From fe17673799c4432e586d0bf20b1a306371d2ea56 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Mon, 22 Nov 2021 18:17:21 +0100 Subject: kde-plasma/plasma-workspace: systemtray: fix crash and race condition Upstream commits: 931a5441746daf10d9476409f347263719ef6c63 a9fba8b5416dd3b130045ccac40e5412714563ea KDE-bug: https://bugs.kde.org/show_bug.cgi?id=443961 Package-Manager: Portage-3.0.28, Repoman-3.0.3 Signed-off-by: Andreas Sturmlechner --- ...systemtray-check-if-service-already-added.patch | 41 ++++++++++++++++ ...pace-5.23.3-systemtray-fix-race-condition.patch | 54 ++++++++++++++++++++++ .../plasma-workspace-5.23.3-r2.ebuild | 2 + 3 files changed, 97 insertions(+) create mode 100644 kde-plasma/plasma-workspace/files/plasma-workspace-5.23.3-systemtray-check-if-service-already-added.patch create mode 100644 kde-plasma/plasma-workspace/files/plasma-workspace-5.23.3-systemtray-fix-race-condition.patch (limited to 'kde-plasma/plasma-workspace') diff --git a/kde-plasma/plasma-workspace/files/plasma-workspace-5.23.3-systemtray-check-if-service-already-added.patch b/kde-plasma/plasma-workspace/files/plasma-workspace-5.23.3-systemtray-check-if-service-already-added.patch new file mode 100644 index 000000000000..6258b66f6e70 --- /dev/null +++ b/kde-plasma/plasma-workspace/files/plasma-workspace-5.23.3-systemtray-check-if-service-already-added.patch @@ -0,0 +1,41 @@ +From 931a5441746daf10d9476409f347263719ef6c63 Mon Sep 17 00:00:00 2001 +From: Fushan Wen +Date: Mon, 1 Nov 2021 22:17:53 +0800 +Subject: [PATCH] systemtray: Check if a service is already added before + processing QDBusReply + +Due to async nature of QDBusPendingReply, services could be already +registered by QDBusServiceWatcher when the pending reply takes a long +time to finish, so it's possible that QDBusServiceWatcher::serviceRegistered +signal is emitted before the pending reply emits QDBusPendingCallWatcher::finished, +which will make the same service added twice and crash plasmashell. + +We need to check if a service is already added in m_sniServices before +processing registered items in QDBusReply. + +BUG: 443961 + + +(cherry picked from commit c0b8f6871e75bbc268165844ad5780f13a5f88ac) +--- + applets/systemtray/statusnotifieritemhost.cpp | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/applets/systemtray/statusnotifieritemhost.cpp b/applets/systemtray/statusnotifieritemhost.cpp +index c17eedd6c..4108b2b82 100644 +--- a/applets/systemtray/statusnotifieritemhost.cpp ++++ b/applets/systemtray/statusnotifieritemhost.cpp +@@ -101,7 +101,9 @@ void StatusNotifierItemHost::registerWatcher(const QString &service) + QDBusReply reply = *watcher; + QStringList registeredItems = reply.value().variant().toStringList(); + foreach (const QString &service, registeredItems) { +- addSNIService(service); ++ if (!m_sniServices.contains(service)) { // due to async nature of this call, service may be already there ++ addSNIService(service); ++ } + } + }); + +-- +GitLab + diff --git a/kde-plasma/plasma-workspace/files/plasma-workspace-5.23.3-systemtray-fix-race-condition.patch b/kde-plasma/plasma-workspace/files/plasma-workspace-5.23.3-systemtray-fix-race-condition.patch new file mode 100644 index 000000000000..bbe9a152c608 --- /dev/null +++ b/kde-plasma/plasma-workspace/files/plasma-workspace-5.23.3-systemtray-fix-race-condition.patch @@ -0,0 +1,54 @@ +From a9fba8b5416dd3b130045ccac40e5412714563ea Mon Sep 17 00:00:00 2001 +From: Fushan Wen +Date: Sat, 20 Nov 2021 21:04:06 +0800 +Subject: [PATCH] systemtray: Connect to StatusNotifierWatcher before + initializing QDBusPendingReply + +This fixes a race condition. + + +(cherry picked from commit 644588739e617cfde8ee097dff4a72cc08c421aa) +--- + applets/systemtray/statusnotifieritemhost.cpp | 19 +++++++++---------- + 1 file changed, 9 insertions(+), 10 deletions(-) + +diff --git a/applets/systemtray/statusnotifieritemhost.cpp b/applets/systemtray/statusnotifieritemhost.cpp +index 4108b2b82..117c29f17 100644 +--- a/applets/systemtray/statusnotifieritemhost.cpp ++++ b/applets/systemtray/statusnotifieritemhost.cpp +@@ -93,6 +93,15 @@ void StatusNotifierItemHost::registerWatcher(const QString &service) + m_statusNotifierWatcher->path(), + m_statusNotifierWatcher->connection()); + ++ connect(m_statusNotifierWatcher, ++ &OrgKdeStatusNotifierWatcherInterface::StatusNotifierItemRegistered, ++ this, ++ &StatusNotifierItemHost::serviceRegistered); ++ connect(m_statusNotifierWatcher, ++ &OrgKdeStatusNotifierWatcherInterface::StatusNotifierItemUnregistered, ++ this, ++ &StatusNotifierItemHost::serviceUnregistered); ++ + QDBusPendingReply pendingItems = propetriesIface.Get(m_statusNotifierWatcher->interface(), "RegisteredStatusNotifierItems"); + + QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(pendingItems, this); +@@ -106,16 +115,6 @@ void StatusNotifierItemHost::registerWatcher(const QString &service) + } + } + }); +- +- connect(m_statusNotifierWatcher, +- &OrgKdeStatusNotifierWatcherInterface::StatusNotifierItemRegistered, +- this, +- &StatusNotifierItemHost::serviceRegistered); +- connect(m_statusNotifierWatcher, +- &OrgKdeStatusNotifierWatcherInterface::StatusNotifierItemUnregistered, +- this, +- &StatusNotifierItemHost::serviceUnregistered); +- + } else { + delete m_statusNotifierWatcher; + m_statusNotifierWatcher = nullptr; +-- +GitLab + diff --git a/kde-plasma/plasma-workspace/plasma-workspace-5.23.3-r2.ebuild b/kde-plasma/plasma-workspace/plasma-workspace-5.23.3-r2.ebuild index 5bc9e1a28269..9d9161b72295 100644 --- a/kde-plasma/plasma-workspace/plasma-workspace-5.23.3-r2.ebuild +++ b/kde-plasma/plasma-workspace/plasma-workspace-5.23.3-r2.ebuild @@ -151,6 +151,8 @@ PATCHES=( "${FILESDIR}/${PN}-5.21.5-split-libkworkspace.patch" # downstream "${FILESDIR}/${PN}-5.22.5-krunner-cwd-at-home.patch" # TODO upstream: KDE-bug 432975, bug 767478 "${FILESDIR}/${P}-baloosearchrunner-emit-DBus-error-when-disabled.patch" # KDE-bug 445342 + "${FILESDIR}/${P}-systemtray-check-if-service-already-added.patch" # KDE-bug 443961 + "${FILESDIR}/${P}-systemtray-fix-race-condition.patch" ) src_prepare() { -- cgit v1.2.3-65-gdbad