D11438: Use a shared pointer for keeping track of notifications
Aleix Pol Gonzalez
noreply at phabricator.kde.org
Mon Mar 19 00:14:47 UTC 2018
apol added a comment.
I agree that the problem is somewhere over there, but I can't put he finger on it. I don't think the shared pointer is going to entirely solve the issue though.
Notifications are dbus interfaces, keeping them alive after they are deleted won't do much good. I had this proof of concept locally to see if it was better, and it seems better but not really.
Also I haven't had a crash since the last fix, I do see empty notifications on the plasmoid sometimes though.
diff --git a/plugins/notifications/notificationsdbusinterface.cpp b/plugins/notifications/notificationsdbusinterface.cpp
index 343d1149..fc3d83a2 100644
--- a/plugins/notifications/notificationsdbusinterface.cpp
+++ b/plugins/notifications/notificationsdbusinterface.cpp
@@ -69,6 +69,7 @@ void NotificationsDbusInterface::processPacket(const NetworkPacket& np)
if (!m_internalIdToPublicId.contains(id)) {
Notification* noti = new Notification(np, this);
+ connect(noti, &QObject::destroyed, this, [this, id](){ removeNotification(id); });
if (noti->isReady()) {
addNotification(noti);
diff --git a/plugins/notifications/notificationsdbusinterface.h b/plugins/notifications/notificationsdbusinterface.h
index 0cf23c63..fdb3d2a9 100644
--- a/plugins/notifications/notificationsdbusinterface.h
+++ b/plugins/notifications/notificationsdbusinterface.h
@@ -66,7 +66,7 @@ private /*methods*/:
private /*attributes*/:
const Device* m_device;
KdeConnectPlugin* m_plugin;
- QHash<QString, QPointer<Notification>> m_notifications;
+ QHash<QString, Notification*> m_notifications;
QHash<QString, QString> m_internalIdToPublicId;
int m_lastId;
};
REPOSITORY
R224 KDE Connect
REVISION DETAIL
https://phabricator.kde.org/D11438
To: mtijink, #kde_connect
Cc: apol, nicolasfella, #kde_connect
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdeconnect/attachments/20180319/3cf6d99a/attachment.html>
More information about the KDEConnect
mailing list