Merge lp:~loic.molinari/unity/unity-clean-up-at-destruction-2 into lp:unity

Proposed by Loïc Molinari
Status: Merged
Merged at revision: 1140
Proposed branch: lp:~loic.molinari/unity/unity-clean-up-at-destruction-2
Merge into: lp:unity
Diff against target: 243 lines (+53/-16)
10 files modified
src/BamfLauncherIcon.cpp (+4/-1)
src/Launcher.cpp (+9/-4)
src/Launcher.h (+1/-0)
src/LauncherController.cpp (+5/-1)
src/LauncherController.h (+2/-0)
src/LauncherModel.cpp (+9/-0)
src/PanelController.cpp (+2/-0)
src/PanelView.cpp (+6/-1)
src/unityshell.cpp (+14/-9)
src/unityshell.h (+1/-0)
To merge this branch: bzr merge lp:~loic.molinari/unity/unity-clean-up-at-destruction-2
Reviewer Review Type Date Requested Status
Didier Roche-Tolomelli Approve
Review via email: mp+57701@code.launchpad.net

Description of the change

That branch plugs several memory leaks and removes some signal connections at destruction.

To post a comment you must log in.
Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Approved with LauncherWindow Unreference back.

I still have a crasher in ccsm though, so don't set the bug as fix committed, but still a step forward! Nice work, approved :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/BamfLauncherIcon.cpp'
2--- src/BamfLauncherIcon.cpp 2011-04-10 17:52:26 +0000
3+++ src/BamfLauncherIcon.cpp 2011-04-14 16:16:40 +0000
4@@ -165,9 +165,12 @@
5 BamfLauncherIcon::~BamfLauncherIcon()
6 {
7 g_object_set_qdata (G_OBJECT (m_App), g_quark_from_static_string ("unity-seen"), GINT_TO_POINTER (0));
8+
9+ // FIXME(loicm): _menu_items stores invalid objects at that point for some
10+ // unknow reasons generating GLib warnings. Also it seems like some items
11+ // are leaked.
12 g_signal_handler_disconnect ((gpointer) _menu_items["Pin"],
13 _menu_callbacks["Pin"]);
14-
15 g_signal_handler_disconnect ((gpointer) _menu_items["Quit"],
16 _menu_callbacks["Quit"]);
17
18
19=== modified file 'src/Launcher.cpp'
20--- src/Launcher.cpp 2011-04-14 15:05:07 +0000
21+++ src/Launcher.cpp 2011-04-14 16:16:40 +0000
22@@ -459,8 +459,8 @@
23 NULL);
24
25 _settings = g_settings_new ("com.canonical.Unity.Launcher");
26- g_signal_connect (_settings, "changed",
27- (GCallback)(Launcher::SettingsChanged), this);
28+ _settings_changed_id = g_signal_connect (
29+ _settings, "changed", (GCallback)(Launcher::SettingsChanged), this);
30 SettingsChanged (_settings, (gchar *)"shows-on-edge", this);
31
32 SetDndEnabled (false, true);
33@@ -494,6 +494,10 @@
34 if (_super_hide_launcher_handle)
35 g_source_remove (_super_hide_launcher_handle);
36
37+ if (_settings_changed_id != 0)
38+ g_signal_handler_disconnect ((gpointer) _settings, _settings_changed_id);
39+ g_object_unref (_settings);
40+
41 // disconnect the huge number of signal-slot callbacks
42 if (_set_hidden_connection.connected ())
43 _set_hidden_connection.disconnect ();
44@@ -570,6 +574,9 @@
45 if (_ubus_handles[i] != 0)
46 ubus_server_unregister_interest (ubus, _ubus_handles[i]);
47 }
48+
49+ delete _hover_machine;
50+ delete _hide_machine;
51 }
52
53 /* Introspection */
54@@ -2193,7 +2200,6 @@
55
56 void Launcher::OnIconAdded (LauncherIcon *icon)
57 {
58- icon->Reference ();
59 EnsureAnimation();
60
61 icon->_xform_coords["HitArea"] = new nux::Vector4[4];
62@@ -2238,7 +2244,6 @@
63 if (icon == _drag_icon)
64 _drag_icon = 0;
65
66- icon->UnReference ();
67 EnsureAnimation();
68 RemoveChild (icon);
69 }
70
71=== modified file 'src/Launcher.h'
72--- src/Launcher.h 2011-04-13 07:49:27 +0000
73+++ src/Launcher.h 2011-04-14 16:16:40 +0000
74@@ -556,6 +556,7 @@
75 sigc::connection _on_drag_finish_connection;
76
77 GSettings *_settings;
78+ guint32 _settings_changed_id;
79
80 guint _ubus_handles[5];
81 };
82
83=== modified file 'src/LauncherController.cpp'
84--- src/LauncherController.cpp 2011-04-05 18:46:57 +0000
85+++ src/LauncherController.cpp 2011-04-14 16:16:40 +0000
86@@ -85,9 +85,13 @@
87 if (_on_remote_model_entry_removed_connection.connected ())
88 _on_remote_model_entry_removed_connection.disconnect ();
89
90+ if (_matcher != NULL && _on_view_opened_id != 0)
91+ g_signal_handler_disconnect ((gpointer) _matcher, _on_view_opened_id);
92+
93 _favorite_store->UnReference ();
94 delete _place_section;
95 delete _device_section;
96+ delete _model;
97 }
98
99 void
100@@ -357,7 +361,7 @@
101 }
102
103 apps = bamf_matcher_get_applications (_matcher);
104- g_signal_connect (_matcher, "view-opened", (GCallback) &LauncherController::OnViewOpened, this);
105+ _on_view_opened_id = g_signal_connect (_matcher, "view-opened", (GCallback) &LauncherController::OnViewOpened, this);
106
107 for (l = apps; l; l = l->next)
108 {
109
110=== modified file 'src/LauncherController.h'
111--- src/LauncherController.h 2011-03-31 20:04:23 +0000
112+++ src/LauncherController.h 2011-04-14 16:16:40 +0000
113@@ -73,6 +73,8 @@
114 sigc::connection _on_remote_model_entry_added_connection;
115 sigc::connection _on_remote_model_entry_removed_connection;
116
117+ guint32 _on_view_opened_id;
118+
119 void SortAndSave ();
120
121 void OnIconAdded (LauncherIcon *icon);
122
123=== modified file 'src/LauncherModel.cpp'
124--- src/LauncherModel.cpp 2011-03-29 14:36:45 +0000
125+++ src/LauncherModel.cpp 2011-04-14 16:16:40 +0000
126@@ -33,6 +33,15 @@
127
128 LauncherModel::~LauncherModel()
129 {
130+ for (iterator it = _inner_shelf.begin (); it != _inner_shelf.end (); ++it)
131+ reinterpret_cast<LauncherIcon*> (*it)->UnReference ();
132+ _inner_shelf.clear ();
133+
134+ for (iterator it = _inner_main.begin (); it != _inner_main.end (); ++it)
135+ reinterpret_cast<LauncherIcon*> (*it)->UnReference ();
136+ _inner_main.clear ();
137+
138+ _inner.clear ();
139 }
140
141 bool LauncherModel::IconShouldShelf (LauncherIcon *icon)
142
143=== modified file 'src/PanelController.cpp'
144--- src/PanelController.cpp 2011-04-06 22:11:07 +0000
145+++ src/PanelController.cpp 2011-04-14 16:16:40 +0000
146@@ -151,6 +151,8 @@
147 PanelView *view;
148 nux::HLayout *layout;
149
150+ // FIXME(loicm): Several objects created here are leaked.
151+
152 layout = new nux::HLayout();
153
154 view = new PanelView ();
155
156=== modified file 'src/PanelView.cpp'
157--- src/PanelView.cpp 2011-04-14 12:07:19 +0000
158+++ src/PanelView.cpp 2011-04-14 16:16:40 +0000
159@@ -85,8 +85,13 @@
160 _on_entry_activate_request_connection.disconnect ();
161 _on_entry_activated_connection.disconnect ();
162 _on_synced_connection.disconnect ();
163-
164+
165+ _layout->UnReference ();
166+ _home_button->UnReference ();
167+ _menu_view->UnReference ();
168+ _tray->UnReference ();
169 _style->UnReference ();
170+
171 delete _remote;
172 delete _bg_layer;
173 }
174
175=== modified file 'src/unityshell.cpp'
176--- src/unityshell.cpp 2011-04-14 03:07:09 +0000
177+++ src/unityshell.cpp 2011-04-14 16:16:40 +0000
178@@ -986,8 +986,13 @@
179
180 UnityScreen::~UnityScreen ()
181 {
182+ delete placesController;
183+ panelController->UnReference ();
184+ delete controller;
185+ layout->UnReference ();
186+ launcher->UnReference ();
187 launcherWindow->UnReference ();
188- panelController->UnReference ();
189+
190 unity_a11y_finalize ();
191
192 UBusServer* ubus = ubus_server_get_default ();
193@@ -999,6 +1004,8 @@
194
195 if (relayoutSourceId != 0)
196 g_source_remove (relayoutSourceId);
197+
198+ delete wt;
199 }
200
201 /* Start up the launcher */
202@@ -1010,23 +1017,21 @@
203
204 LOGGER_START_PROCESS ("initLauncher-Launcher");
205 self->launcherWindow = new nux::BaseWindow(TEXT("LauncherWindow"));
206- self->launcherWindow->SinkReference ();
207 self->launcher = new Launcher(self->launcherWindow, self->screen);
208 self->launcher->hidden_changed.connect (sigc::mem_fun (self, &UnityScreen::OnLauncherHiddenChanged));
209
210 self->AddChild (self->launcher);
211
212- nux::HLayout* layout = new nux::HLayout();
213-
214- layout->AddView(self->launcher, 1);
215- layout->SetContentDistribution(nux::eStackLeft);
216- layout->SetVerticalExternalMargin(0);
217- layout->SetHorizontalExternalMargin(0);
218+ self->layout = new nux::HLayout();
219+ self->layout->AddView(self->launcher, 1);
220+ self->layout->SetContentDistribution(nux::eStackLeft);
221+ self->layout->SetVerticalExternalMargin(0);
222+ self->layout->SetHorizontalExternalMargin(0);
223
224 self->controller = new LauncherController (self->launcher, self->screen, self->launcherWindow);
225
226 self->launcherWindow->SetConfigureNotifyCallback(&UnityScreen::launcherWindowConfigureCallback, self);
227- self->launcherWindow->SetLayout(layout);
228+ self->launcherWindow->SetLayout(self->layout);
229 self->launcherWindow->SetBackgroundColor(nux::Color(0x00000000));
230 self->launcherWindow->ShowWindow(true);
231 self->launcherWindow->EnableInputWindow(true, "launcher", false, false);
232
233=== modified file 'src/unityshell.h'
234--- src/unityshell.h 2011-04-13 07:49:27 +0000
235+++ src/unityshell.h 2011-04-14 16:16:40 +0000
236@@ -216,6 +216,7 @@
237 GestureEngine *gestureEngine;
238 nux::WindowThread *wt;
239 nux::BaseWindow *launcherWindow;
240+ nux::HLayout *layout;
241 nux::BaseWindow *panelWindow;
242 nux::Geometry lastTooltipArea;
243 DebugDBusInterface *debugger;