From a1d82729bc4a97650080e4948dd98e92b4b98aca Mon Sep 17 00:00:00 2001 From: outfoxxed Date: Mon, 29 Apr 2024 18:31:35 -0700 Subject: [PATCH] service/tray: log failures when calling Activate or SecondaryActivate --- src/services/status_notifier/item.cpp | 40 +++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/src/services/status_notifier/item.cpp b/src/services/status_notifier/item.cpp index 51047786..8d55ba2a 100644 --- a/src/services/status_notifier/item.cpp +++ b/src/services/status_notifier/item.cpp @@ -3,6 +3,7 @@ #include #include +#include #include #include #include @@ -175,9 +176,44 @@ QPixmap StatusNotifierItem::createPixmap(const QSize& size) const { return pixmap; } -void StatusNotifierItem::activate() { this->item->Activate(0, 0); } +void StatusNotifierItem::activate() { + auto pendingCall = this->item->Activate(0, 0); + auto* call = new QDBusPendingCallWatcher(pendingCall, this); -void StatusNotifierItem::secondaryActivate() { this->item->SecondaryActivate(0, 0); } + auto responseCallback = [this](QDBusPendingCallWatcher* call) { + const QDBusPendingReply<> reply = *call; + + if (reply.isError()) { + qCWarning(logStatusNotifierItem).noquote() + << "Error calling Activate method of StatusNotifierItem" << this->properties.toString(); + qCWarning(logStatusNotifierItem) << reply.error(); + } + + delete call; + }; + + QObject::connect(call, &QDBusPendingCallWatcher::finished, this, responseCallback); +} + +void StatusNotifierItem::secondaryActivate() { + auto pendingCall = this->item->SecondaryActivate(0, 0); + auto* call = new QDBusPendingCallWatcher(pendingCall, this); + + auto responseCallback = [this](QDBusPendingCallWatcher* call) { + const QDBusPendingReply<> reply = *call; + + if (reply.isError()) { + qCWarning(logStatusNotifierItem).noquote() + << "Error calling SecondaryActivate method of StatusNotifierItem" + << this->properties.toString(); + qCWarning(logStatusNotifierItem) << reply.error(); + } + + delete call; + }; + + QObject::connect(call, &QDBusPendingCallWatcher::finished, this, responseCallback); +} void StatusNotifierItem::scroll(qint32 delta, bool horizontal) { this->item->Scroll(delta, horizontal ? "horizontal" : "vertical");