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
1=== modified file 'include/Notification.h'
2--- include/Notification.h 2013-10-01 08:49:54 +0000
3+++ include/Notification.h 2013-10-15 07:33:12 +0000
4@@ -109,6 +109,7 @@
5 void setType(Type type);
6 ActionModel* getActions() const;
7 void setActions(QStringList actions);
8+ void detachFromServer();
9
10 QVariantMap getHints() const;
11 void setHints(const QVariantMap& hints);
12
13=== modified file 'src/Notification.cpp'
14--- src/Notification.cpp 2013-10-02 23:05:05 +0000
15+++ src/Notification.cpp 2013-10-15 07:33:12 +0000
16@@ -192,6 +192,19 @@
17 }
18 }
19
20+void Notification::detachFromServer() {
21+ /*
22+ * FIXME. This function should not exist. In fact
23+ * a notification should not need to know the server
24+ * it is connected to. Instead the way p->server
25+ * is used needs to be converted into a proper
26+ * Qt signal. Unfortunately, due to deadlines,
27+ * we did not have time. The next time this is worked
28+ * on, fix this properly.
29+ */
30+ p->server = nullptr;
31+}
32+
33 QVariantMap Notification::getHints() const {
34 return p->hints;
35 }
36
37=== modified file 'src/NotificationModel.cpp'
38--- src/NotificationModel.cpp 2013-10-01 08:49:54 +0000
39+++ src/NotificationModel.cpp 2013-10-15 07:33:12 +0000
40@@ -45,6 +45,18 @@
41 }
42
43 NotificationModel::~NotificationModel() {
44+ for(int i=0; i<p->ephemeralQueue.size(); i++) {
45+ p->ephemeralQueue[i]->detachFromServer();
46+ }
47+ for(int i=0; i<p->interactiveQueue.size(); i++) {
48+ p->interactiveQueue[i]->detachFromServer();
49+ }
50+ for(int i=0; i<p->snapQueue.size(); i++) {
51+ p->snapQueue[i]->detachFromServer();
52+ }
53+ for(int i=0; i<p->displayedNotifications.size(); i++) {
54+ p->displayedNotifications[i]->detachFromServer();
55+ }
56 }
57
58 int NotificationModel::rowCount(const QModelIndex &parent) const {

Subscribers

People subscribed via source and target branches

to all changes: