Merge lp:~agateau/unity-2d/unity-applications-memleaks into lp:unity-2d/3.0

Proposed by Aurélien Gâteau
Status: Merged
Approved by: Aurélien Gâteau
Approved revision: 495
Merged at revision: 495
Proposed branch: lp:~agateau/unity-2d/unity-applications-memleaks
Merge into: lp:unity-2d/3.0
Diff against target: 81 lines (+12/-7)
3 files modified
launcher/UnityApplications/iconimageprovider.cpp (+2/-0)
launcher/UnityApplications/launcherapplication.cpp (+9/-6)
launcher/UnityApplications/webfavorite.cpp (+1/-1)
To merge this branch: bzr merge lp:~agateau/unity-2d/unity-applications-memleaks
Reviewer Review Type Date Requested Status
Olivier Tilloy (community) Approve
Review via email: mp+55491@code.launchpad.net

Commit message

[launcher] Fix some memory leaks.

Description of the change

Plug some memory leaks I found while valgrinding unity-2d-launcher.

I think we could use a GObjectScopedPointer to handle GObject pointers. Will see if I can write one.

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

Style nitpick:

- return m_application->windows()->size();
+ QScopedPointer<BamfWindowList> lst(m_application->windows());
+ return lst->size();

Could you please rename 'lst' to a more explicit name, e.g. 'windows'?

Revision history for this message
Olivier Tilloy (osomon) wrote :

Good catches. I verified that the fixes make sense from a programming standpoint, and that they don’t seem to introduce functional regressions. Once you fix the above nitpick, please go ahead and approve so it can be merged.

review: Approve
Revision history for this message
Bob The Builder (bobthebuilder-deactivatedaccount) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'launcher/UnityApplications/iconimageprovider.cpp'
2--- launcher/UnityApplications/iconimageprovider.cpp 2011-03-09 13:23:04 +0000
3+++ launcher/UnityApplications/iconimageprovider.cpp 2011-03-30 13:47:12 +0000
4@@ -126,6 +126,8 @@
5 requestedSize.width(),
6 (GtkIconLookupFlags)0);
7 GdkPixbuf *pixbuf = gtk_icon_info_load_icon(icon_info, NULL);
8+ gtk_icon_info_free(icon_info);
9+ g_object_unref(g_icon);
10
11 /* FIXME: maybe an exception should be raised instead? */
12 if (pixbuf == NULL) {
13
14=== modified file 'launcher/UnityApplications/launcherapplication.cpp'
15--- launcher/UnityApplications/launcherapplication.cpp 2011-03-29 14:23:11 +0000
16+++ launcher/UnityApplications/launcherapplication.cpp 2011-03-30 13:47:12 +0000
17@@ -38,12 +38,14 @@
18 // libunity-2d
19 #include <unity2dtr.h>
20
21+// Qt
22 #include <QDebug>
23 #include <QAction>
24 #include <QDBusInterface>
25 #include <QDBusReply>
26 #include <QFile>
27 #include <QFileSystemWatcher>
28+#include <QScopedPointer>
29
30 extern "C" {
31 #include <libsn/sn.h>
32@@ -99,12 +101,8 @@
33 m_snStartupSequence = NULL;
34 }
35
36- if (m_application != NULL) {
37- m_application->disconnect(this);
38- m_application = NULL;
39- }
40-
41 if (m_appInfo != NULL) {
42+ g_object_unref(m_appInfo);
43 m_appInfo = NULL;
44 }
45 }
46@@ -136,7 +134,8 @@
47 return 0;
48 }
49
50- return m_application->windows()->size();
51+ QScopedPointer<BamfWindowList> windows(m_application->windows());
52+ return windows->size();
53 }
54
55 bool
56@@ -271,6 +270,10 @@
57 QByteArray byte_array = desktop_file.toUtf8();
58 gchar *file = byte_array.data();
59
60+ if (m_appInfo) {
61+ g_object_unref(m_appInfo);
62+ }
63+
64 if(desktop_file.startsWith("/")) {
65 /* It looks like a full path to a desktop file */
66 m_appInfo = g_desktop_app_info_new_from_filename(file);
67
68=== modified file 'launcher/UnityApplications/webfavorite.cpp'
69--- launcher/UnityApplications/webfavorite.cpp 2011-03-09 13:23:04 +0000
70+++ launcher/UnityApplications/webfavorite.cpp 2011-03-30 13:47:12 +0000
71@@ -100,9 +100,9 @@
72 if (loaded) {
73 g_key_file_set_string(keyFile, "Desktop Entry", key.toUtf8().constData(), value.toUtf8().constData());
74 QByteArray contents = g_key_file_to_data(keyFile, NULL, NULL);
75- g_key_file_free(keyFile);
76 writeDesktopFile(contents);
77 }
78+ g_key_file_free(keyFile);
79 }
80
81 void

Subscribers

People subscribed via source and target branches