Merge lp://staging/~lukas-kde/unity-notifications/fix-1453958 into lp://staging/unity-notifications

Proposed by Lukáš Tinkl
Status: Merged
Approved by: Pete Woods
Approved revision: 231
Merged at revision: 236
Proposed branch: lp://staging/~lukas-kde/unity-notifications/fix-1453958
Merge into: lp://staging/unity-notifications
Diff against target: 422 lines (+145/-93)
9 files modified
include/ActionModel.h (+4/-4)
include/Notification.h (+3/-0)
include/NotificationModel.h (+3/-3)
include/NotificationPlugin.h (+2/-2)
src/Notification.cpp (+3/-3)
src/NotificationModel.cpp (+45/-37)
src/NotificationServer.cpp (+6/-6)
test/CMakeLists.txt (+0/-1)
test/notificationtest.cpp (+79/-37)
To merge this branch: bzr merge lp://staging/~lukas-kde/unity-notifications/fix-1453958
Reviewer Review Type Date Requested Status
Pete Woods Approve
Review via email: mp+274163@code.staging.launchpad.net

Commit message

Merge and rebase older code to fix notifications crashing on closing

Description of the change

Merge and rebase older code to fix notifications crashing on closing

Cf. https://bugs.launchpad.net/unity-notifications/+bug/1453958

Original message from lp:~macslow/unity-notifications/fix-1453958:

Plugged memory-leaks causing the backend to crash the unity8-notification-plugin and updated unit-tests. Deleting notifications in reverse order of insertion no longer result the segfault forced by the provided python-script.

Checklist:

* Are there any related MPs required for this MP to build/function as expected? Please list.

No

* Did you perform an exploratory manual test run of your code change and any related functionality?

Yes

* Did you make sure that your branch does not contain spurious tags?

Yes

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

Yes

 * If you changed the UI, has there been a design review?

N/A

To post a comment you must log in.
Revision history for this message
Pete Woods (pete-woods) wrote :

When making a QSharedPointer use deleteLater, you should really pass in a custom deleter like so:

   QSharedPointer<MyClass> instance(new Myclass(param), &QObject::deleteLater)

i.e. at object creation time. It's risky to grab the raw pointer from a shared pointer and ask it to delete at some point.

review: Disapprove
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

> When making a QSharedPointer use deleteLater, you should really pass in a
> custom deleter like so:
>
> QSharedPointer<MyClass> instance(new Myclass(param), &QObject::deleteLater)
>
> i.e. at object creation time. It's risky to grab the raw pointer from a shared
> pointer and ask it to delete at some point.

Ack, &QObject::deleteLater on construction and QSharedPointer::clear() when releasing it.

229. By Lukáš Tinkl

specify &QObject::deleteLater deleter at construction,
clear the shared pointer on destruction instead

Revision history for this message
Pete Woods (pete-woods) wrote :

Technically you don't even need the ::clear, as it will go out of scope naturally, (it's erased from the map, and the stack variable n goes out of scope). If you can be bothered, I would also remove all calls to n->clear();

230. By Lukáš Tinkl

remove the superfluous clear()

Revision history for this message
Lukáš Tinkl (lukas-kde) wrote :

> Technically you don't even need the ::clear, as it will go out of scope
> naturally, (it's erased from the map, and the stack variable n goes out of
> scope). If you can be bothered, I would also remove all calls to n->clear();

Done

231. By Lukáš Tinkl

add missing override keywords

Revision history for this message
Pete Woods (pete-woods) :
review: Approve
Revision history for this message
Pete Woods (pete-woods) wrote :

Thanks for the fixes!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches

to all changes: