Merge lp:~aacid/unity-2d/fix_memory_leaks_from_qtbamf_lists into lp:unity-2d

Proposed by Albert Astals Cid
Status: Merged
Approved by: Lohith D Shivamurthy
Approved revision: 836
Merged at revision: 836
Proposed branch: lp:~aacid/unity-2d/fix_memory_leaks_from_qtbamf_lists
Merge into: lp:unity-2d
Diff against target: 47 lines (+4/-4)
3 files modified
libunity-2d-private/src/launcherapplication.cpp (+1/-1)
libunity-2d-private/src/windowinfo.cpp (+1/-1)
libunity-2d-private/src/windowslist.cpp (+2/-2)
To merge this branch: bzr merge lp:~aacid/unity-2d/fix_memory_leaks_from_qtbamf_lists
Reviewer Review Type Date Requested Status
Lohith D Shivamurthy (community) Needs Information
Review via email: mp+87259@code.launchpad.net

Description of the change

Use QScopedPointers to properly delete the lists returned from qtbamf

To post a comment you must log in.
Revision history for this message
Albert Astals Cid (aacid) wrote :
Revision history for this message
Lohith D Shivamurthy (dyams) wrote :

Albert,
Very nice. Good catch. I can approve the branch already.

I wanted to get clarified for one thing more. Well, In a way, It mayn't be related to your current branch. But just in case if you are also as curious as me, go through the following paragraph.

I just observed one corner case not being handled properly in
  <code> WindowInfo::getBamfWindowForApplication </code> line #46, in windowinfo.cpp
Currently whats happening is, even when there is no match found for given 'xid' in the list of applicatio->windows(),
The function still returns a valid BamfWindow pointer, which is the last item in the list.
 <code> window = windows->at(i); </code> line #56, windowinfo.cpp
Should we add
  <code> window = NULL </code>
line below:
  <code>
    if (window->xid() == xid) { line # 57, 58 & 59, in windowinfo.cpp
      break;
    }
  </code>
?

Correct me if am wrong. please.

review: Needs Information
Revision history for this message
Albert Astals Cid (aacid) wrote :

Right, seems if that the xid is not found we are returning the last window, probably not the desired behaviour of the function.

That was already the old behaviour before my patch, i can fix that if you want, but for me it makes more sense to do so in a different merge request to keep stuff more contained. What to you think?

Revision history for this message
Albert Astals Cid (aacid) wrote :

As discussed over IRC, fixing the other issue in a separate merge request https://code.launchpad.net/~aacid/unity-2d/fixGetBamfWindowForApplication/+merge/87321

Revision history for this message
Lohith D Shivamurthy (dyams) wrote :

Nice.
Thank you.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libunity-2d-private/src/launcherapplication.cpp'
2--- libunity-2d-private/src/launcherapplication.cpp 2011-11-24 08:45:18 +0000
3+++ libunity-2d-private/src/launcherapplication.cpp 2012-01-02 15:37:24 +0000
4@@ -763,7 +763,7 @@
5
6 if (compiz.isValid()) {
7 Qt::HANDLE root = QX11Info::appRootWindow();
8- BamfUintList* xids = m_application->xids();
9+ QScopedPointer<BamfUintList> xids(m_application->xids());
10 QStringList fragments;
11 for (int i = 0; i < xids->size(); i++) {
12 uint xid = xids->at(i);
13
14=== modified file 'libunity-2d-private/src/windowinfo.cpp'
15--- libunity-2d-private/src/windowinfo.cpp 2011-08-01 13:04:32 +0000
16+++ libunity-2d-private/src/windowinfo.cpp 2012-01-02 15:37:24 +0000
17@@ -51,7 +51,7 @@
18 }
19
20 BamfWindow *window = NULL;
21- BamfWindowList *windows = application->windows();
22+ QScopedPointer<BamfWindowList> windows(application->windows());
23 for (int i = 0; i < windows->size(); i++) {
24 window = windows->at(i);
25 if (window->xid() == xid) {
26
27=== modified file 'libunity-2d-private/src/windowslist.cpp'
28--- libunity-2d-private/src/windowslist.cpp 2011-07-29 13:49:34 +0000
29+++ libunity-2d-private/src/windowslist.cpp 2012-01-02 15:37:24 +0000
30@@ -85,7 +85,7 @@
31 QList<BamfApplication*> applications;
32
33 /* List the windows of all the applications */
34- BamfApplicationList *allapplications = matcher.applications();
35+ QScopedPointer<BamfApplicationList> allapplications(matcher.applications());
36 for (int i = 0; i < allapplications->size(); i++) {
37 applications.append(allapplications->at(i));
38 }
39@@ -97,7 +97,7 @@
40 continue;
41 }
42
43- BamfWindowList *bamfWindows = application->windows();
44+ QScopedPointer<BamfWindowList> bamfWindows(application->windows());
45 for (int i = 0; i < bamfWindows->size(); i++) {
46 BamfWindow* window = bamfWindows->at(i);
47 if (!window->user_visible()) {

Subscribers

People subscribed via source and target branches