Merge lp:~jpakkane/unity-notifications/lifecycle-fix into lp:unity-notifications

Proposed by Jussi Pakkanen
Status: Merged
Approved by: Michał Sawicz
Approved revision: 182
Merged at revision: 181
Proposed branch: lp:~jpakkane/unity-notifications/lifecycle-fix
Merge into: lp:unity-notifications
Diff against target: 58 lines (+26/-0)
3 files modified
include/Notification.h (+1/-0)
src/Notification.cpp (+13/-0)
src/NotificationModel.cpp (+12/-0)
To merge this branch: bzr merge lp:~jpakkane/unity-notifications/lifecycle-fix
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Michał Sawicz Approve
Review via email: mp+190931@code.launchpad.net

Commit message

Don't call into deleted objects in destructors.

Description of the change

Detach all pending notifications from the server on shutdown so their destructors don't call into already destructed objects.

Do not top approve yet. I'm not convinced that this is the best solution.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

Build failure is due to Jenkins, not the code:

ssh: connect to host bazaar.launchpad.net port 22: Connection refused

Revision history for this message
Michał Sawicz (saviq) wrote :

Yeah, this seems to make sure I'm not getting crashes in notifications any more on exit.

review: Approve (functional)
182. By Jussi Pakkanen

Documented lifecycle fix hackness.

Revision history for this message
Jussi Pakkanen (jpakkane) wrote :

A proper fix would take too much time. Instead documented what needs to be done once the time is right. Feel free to top approve if you feel this to be acceptable.

Revision history for this message
Michał Sawicz (saviq) wrote :

Yeah, let's not crash if possible :)

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'include/Notification.h'
--- include/Notification.h 2013-10-01 08:49:54 +0000
+++ include/Notification.h 2013-10-15 07:33:12 +0000
@@ -109,6 +109,7 @@
109 void setType(Type type);109 void setType(Type type);
110 ActionModel* getActions() const;110 ActionModel* getActions() const;
111 void setActions(QStringList actions);111 void setActions(QStringList actions);
112 void detachFromServer();
112113
113 QVariantMap getHints() const;114 QVariantMap getHints() const;
114 void setHints(const QVariantMap& hints);115 void setHints(const QVariantMap& hints);
115116
=== modified file 'src/Notification.cpp'
--- src/Notification.cpp 2013-10-02 23:05:05 +0000
+++ src/Notification.cpp 2013-10-15 07:33:12 +0000
@@ -192,6 +192,19 @@
192 }192 }
193}193}
194194
195void Notification::detachFromServer() {
196 /*
197 * FIXME. This function should not exist. In fact
198 * a notification should not need to know the server
199 * it is connected to. Instead the way p->server
200 * is used needs to be converted into a proper
201 * Qt signal. Unfortunately, due to deadlines,
202 * we did not have time. The next time this is worked
203 * on, fix this properly.
204 */
205 p->server = nullptr;
206}
207
195QVariantMap Notification::getHints() const {208QVariantMap Notification::getHints() const {
196 return p->hints;209 return p->hints;
197}210}
198211
=== modified file 'src/NotificationModel.cpp'
--- src/NotificationModel.cpp 2013-10-01 08:49:54 +0000
+++ src/NotificationModel.cpp 2013-10-15 07:33:12 +0000
@@ -45,6 +45,18 @@
45}45}
4646
47NotificationModel::~NotificationModel() {47NotificationModel::~NotificationModel() {
48 for(int i=0; i<p->ephemeralQueue.size(); i++) {
49 p->ephemeralQueue[i]->detachFromServer();
50 }
51 for(int i=0; i<p->interactiveQueue.size(); i++) {
52 p->interactiveQueue[i]->detachFromServer();
53 }
54 for(int i=0; i<p->snapQueue.size(); i++) {
55 p->snapQueue[i]->detachFromServer();
56 }
57 for(int i=0; i<p->displayedNotifications.size(); i++) {
58 p->displayedNotifications[i]->detachFromServer();
59 }
48}60}
4961
50int NotificationModel::rowCount(const QModelIndex &parent) const {62int NotificationModel::rowCount(const QModelIndex &parent) const {

Subscribers

People subscribed via source and target branches

to all changes: