Make watcher a pointer so that it doesn't get destroyed too soon

pull/388/head
Loren Burkholder 4 years ago
parent 7727c0d249
commit ac36e92447
  1. 11
      src/notifications/ManagerLinux.cpp

@ -76,16 +76,17 @@ NotificationsManager::postNotification(const QString &roomid,
"/org/freedesktop/Notifications", "/org/freedesktop/Notifications",
"org.freedesktop.Notifications"); "org.freedesktop.Notifications");
auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList); auto call = notifyApp.asyncCallWithArgumentList("Notify", argumentList);
QDBusPendingCallWatcher watcher{QDBusPendingReply{call}}; auto watcher = new QDBusPendingCall{QDBusPendingReply{call}};
connect(&watcher, connect(watcher,
&QDBusPendingCallWatcher::finished, &QDBusPendingCallWatcher::finished,
this, this,
[&watcher, this, &roomid, &eventid]() { [watcher, this, &roomid, &eventid]() {
if (watcher.reply().type() == QDBusMessage::ErrorMessage) if (watcher->reply().type() == QDBusMessage::ErrorMessage)
qDebug() << "D-Bus Error:" << watcher.reply().errorMessage(); qDebug() << "D-Bus Error:" << watcher.reply().errorMessage();
else else
notificationIds[watcher.reply().arguments().first().toUInt()] = notificationIds[watcher->reply().arguments().first().toUInt()] =
roomEventId{roomid, eventid}; roomEventId{roomid, eventid};
delete watcher;
}); });
} }

Loading…
Cancel
Save