service/notifications: emit NotificationClosed after Notify returns

This commit is contained in:
outfoxxed committed 2026-07-10 01:58:38 -07:00
1 parent 98b6d0b7e7
commit 4df562dfb2
2 files changed
+16 -3

No files matched your search

+1
View File
@@ -9,3 +9,4 @@
- Fixed potential crashes from usage of `WindowsetProjection.screens` during monitor unplug.
- Fixed crashes from accessing freed objects laundered through a `ScriptModel`.
- Fixed crashes when a wifi network disappear.
- Fixed unhandled notifications sending `NotificationClosed` out of order.
+15 -3
View File
@@ -8,6 +8,8 @@
#include <qdbusservicewatcher.h>
#include <qlogging.h>
#include <qloggingcategory.h>
#include <qnamespace.h>
#include <qobjectdefs.h>
#include <qqmlengine.h>
#include <qtmetamacros.h>
#include <qtypes.h>
@@ -192,19 +194,29 @@ uint NotificationServer::Notify(
notification->updateProperties(appName, appIcon, summary, body, actions, hints, expireTimeout);
auto id = notification->id();
if (!old) {
emit this->notification(notification);
if (!notification->isTracked()) {
emit this->NotificationClosed(notification->id(), notification->closeReason());
auto closeReason = notification->closeReason();
// Emit NotificationClosed after Notify returns
QMetaObject::invokeMethod(
this,
[this, id, closeReason]() { emit this->NotificationClosed(id, closeReason); },
Qt::QueuedConnection
);
delete notification;
} else {
this->idMap.insert(notification->id(), notification);
this->idMap.insert(id, notification);
this->mNotifications.insertObject(notification);
}
}
return notification->id();
return id;
}
} // namespace qs::service::notifications