diff options
author | Loren Burkholder <computersemiexpert@outlook.com> | 2021-01-20 16:09:25 -0500 |
---|---|---|
committer | Loren Burkholder <computersemiexpert@outlook.com> | 2021-01-20 16:09:25 -0500 |
commit | 1479743e702f2bfba4524ab4dae8cf1134547920 (patch) | |
tree | 4f7754635fe43812b9079edcec6f792a5ccef2d0 /src/notifications | |
parent | Make watcher a pointer so that it doesn't get destroyed too soon (diff) | |
download | nheko-1479743e702f2bfba4524ab4dae8cf1134547920.tar.xz |
Use async call in closeNotification
Diffstat (limited to 'src/notifications')
-rw-r--r-- | src/notifications/ManagerLinux.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/notifications/ManagerLinux.cpp b/src/notifications/ManagerLinux.cpp index ad9e2c21..d9d157fc 100644 --- a/src/notifications/ManagerLinux.cpp +++ b/src/notifications/ManagerLinux.cpp @@ -75,19 +75,17 @@ NotificationsManager::postNotification(const QString &roomid, static QDBusInterface notifyApp("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); - auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); - auto watcher = new QDBusPendingCall{QDBusPendingReply{call}}; - connect(watcher, - &QDBusPendingCallWatcher::finished, - this, - [watcher, this, &roomid, &eventid]() { - if (watcher->reply().type() == QDBusMessage::ErrorMessage) - qDebug() << "D-Bus Error:" << watcher.reply().errorMessage(); - else - notificationIds[watcher->reply().arguments().first().toUInt()] = - roomEventId{roomid, eventid}; - delete watcher; - }); + auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); + auto watcher = new QDBusPendingCallWatcher{QDBusPendingCall{QDBusPendingReply{call}}}; + connect( + watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this, &roomid, &eventid]() { + if (watcher->reply().type() == QDBusMessage::ErrorMessage) + qDebug() << "D-Bus Error:" << watcher->reply().errorMessage(); + else + notificationIds[watcher->reply().arguments().first().toUInt()] = + roomEventId{roomid, eventid}; + delete watcher; + }); } void @@ -99,11 +97,13 @@ NotificationsManager::closeNotification(uint id) static QDBusInterface closeCall("org.freedesktop.Notifications", "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); - QDBusMessage reply = - closeCall.callWithArgumentList(QDBus::AutoDetect, "CloseNotification", argumentList); - if (reply.type() == QDBusMessage::ErrorMessage) { - qDebug() << "D-Bus Error:" << reply.errorMessage(); - } + auto call = closeCall.asyncCallWithArgumentList("CloseNotification", argumentList); + auto watcher = new QDBusPendingCallWatcher{QDBusPendingCall{QDBusPendingReply{call}}}; + connect(watcher, &QDBusPendingCallWatcher::finished, this, [watcher, this]() { + if (watcher->reply().type() == QDBusMessage::ErrorMessage) { + qDebug() << "D-Bus Error:" << watcher->reply().errorMessage(); + }; + }); } void |