Skip to content

Commit a1d8272

Browse files
committed
service/tray: log failures when calling Activate or SecondaryActivate
1 parent c71fdd6 commit a1d8272

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

src/services/status_notifier/item.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <qdbusmetatype.h>
55
#include <qdbuspendingcall.h>
6+
#include <qdbuspendingreply.h>
67
#include <qicon.h>
78
#include <qlogging.h>
89
#include <qloggingcategory.h>
@@ -175,9 +176,44 @@ QPixmap StatusNotifierItem::createPixmap(const QSize& size) const {
175176
return pixmap;
176177
}
177178

178-
void StatusNotifierItem::activate() { this->item->Activate(0, 0); }
179+
void StatusNotifierItem::activate() {
180+
auto pendingCall = this->item->Activate(0, 0);
181+
auto* call = new QDBusPendingCallWatcher(pendingCall, this);
179182

180-
void StatusNotifierItem::secondaryActivate() { this->item->SecondaryActivate(0, 0); }
183+
auto responseCallback = [this](QDBusPendingCallWatcher* call) {
184+
const QDBusPendingReply<> reply = *call;
185+
186+
if (reply.isError()) {
187+
qCWarning(logStatusNotifierItem).noquote()
188+
<< "Error calling Activate method of StatusNotifierItem" << this->properties.toString();
189+
qCWarning(logStatusNotifierItem) << reply.error();
190+
}
191+
192+
delete call;
193+
};
194+
195+
QObject::connect(call, &QDBusPendingCallWatcher::finished, this, responseCallback);
196+
}
197+
198+
void StatusNotifierItem::secondaryActivate() {
199+
auto pendingCall = this->item->SecondaryActivate(0, 0);
200+
auto* call = new QDBusPendingCallWatcher(pendingCall, this);
201+
202+
auto responseCallback = [this](QDBusPendingCallWatcher* call) {
203+
const QDBusPendingReply<> reply = *call;
204+
205+
if (reply.isError()) {
206+
qCWarning(logStatusNotifierItem).noquote()
207+
<< "Error calling SecondaryActivate method of StatusNotifierItem"
208+
<< this->properties.toString();
209+
qCWarning(logStatusNotifierItem) << reply.error();
210+
}
211+
212+
delete call;
213+
};
214+
215+
QObject::connect(call, &QDBusPendingCallWatcher::finished, this, responseCallback);
216+
}
181217

182218
void StatusNotifierItem::scroll(qint32 delta, bool horizontal) {
183219
this->item->Scroll(delta, horizontal ? "horizontal" : "vertical");

0 commit comments

Comments
 (0)