Merge lp:~asac/notify-osd/lp405364_more_memleaks into lp:notify-osd/trunk

Proposed by Alexander Sack
Status: Merged
Approved by: Mirco Müller
Approved revision: 363
Merged at revision: not available
Proposed branch: lp:~asac/notify-osd/lp405364_more_memleaks
Merge into: lp:notify-osd/trunk
Diff against target: None lines
To merge this branch: bzr merge lp:~asac/notify-osd/lp405364_more_memleaks
Reviewer Review Type Date Requested Status
Mirco Müller (community) Approve
Review via email: mp+9502@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexander Sack (asac) wrote :

please push (not merge) to keep my detailed commit logs ;).

Revision history for this message
Mirco Müller (macslow) wrote :

Except for coding-style/formatting I'd say it's ok. While there's still a lot to fix in terms of memory-managment it's a solid start.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'AUTHORS'
2--- AUTHORS 2009-07-24 09:22:01 +0000
3+++ AUTHORS 2009-07-31 10:41:13 +0000
4@@ -13,3 +13,4 @@
5 - Aurélien Gâteau <aurelien.gateau@canonical.com>
6 - Ted Gould <ted@canonical.com>
7 - Bastian "hadess" Nocera <hadess@hadess.net>
8+- Alexander Sack <asac@ubuntu.com>
9
10=== modified file 'src/bubble.c'
11--- src/bubble.c 2009-07-27 15:45:27 +0000
12+++ src/bubble.c 2009-07-31 11:07:29 +0000
13@@ -155,6 +155,7 @@
14
15 static guint g_bubble_signals[LAST_SIGNAL] = { 0 };
16 gint g_pointer[2];
17+static void bubble_del (Bubble* self);
18
19 static void
20 draw_round_rect (cairo_t* cr,
21@@ -367,13 +368,18 @@
22 tmp_surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
23 4 * shadow_radius,
24 4 * shadow_radius);
25- if (cairo_surface_status (tmp_surface) != CAIRO_STATUS_SUCCESS)
26+ if (cairo_surface_status (tmp_surface) != CAIRO_STATUS_SUCCESS) {
27+ if (tmp_surface)
28+ cairo_surface_destroy (tmp_surface);
29 return;
30+ }
31
32 cr_surf = cairo_create (tmp_surface);
33 if (cairo_status (cr_surf) != CAIRO_STATUS_SUCCESS)
34 {
35 cairo_surface_destroy (tmp_surface);
36+ if (cr_surf)
37+ cairo_destroy (cr_surf);
38 return;
39 }
40
41@@ -412,6 +418,8 @@
42 {
43 cairo_surface_destroy (tmp_surface);
44 cairo_surface_destroy (new_surface);
45+ if (pattern)
46+ cairo_pattern_destroy (pattern);
47 return;
48 }
49
50@@ -652,14 +660,21 @@
51 3 * EM2PIXELS (defaults_get_bubble_shadow_size (d), d),
52 3 * EM2PIXELS (defaults_get_bubble_shadow_size (d), d));
53
54- if (cairo_surface_status (scratch) != CAIRO_STATUS_SUCCESS)
55+ g_return_if_fail (scratch);
56+
57+ if (cairo_surface_status (scratch) != CAIRO_STATUS_SUCCESS) {
58+ if (scratch)
59+ cairo_surface_destroy (scratch);
60 return;
61+ }
62
63 // create drawing context for that temp. scratch surface
64 cr = cairo_create (scratch);
65 if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
66 {
67 cairo_surface_destroy (scratch);
68+ if (cr)
69+ cairo_destroy (cr);
70 return;
71 }
72
73@@ -754,8 +769,8 @@
74 if (priv->tile_background_part)
75 tile_destroy (priv->tile_background_part);
76 priv->tile_background_part = tile_new_for_padding (normal, blurred);
77- cairo_surface_destroy (normal);
78- cairo_surface_destroy (blurred);
79+ destroy_cloned_surface (normal);
80+ destroy_cloned_surface (blurred);
81
82 // create surface(s) for full shadow/background tile
83 if (priv->composited)
84@@ -764,14 +779,19 @@
85 normal = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
86 width,
87 height);
88- if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS)
89+ if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) {
90+ if (normal)
91+ cairo_surface_destroy (normal);
92 return;
93+ }
94
95 blurred = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
96 width,
97 height);
98 if (cairo_surface_status (blurred) != CAIRO_STATUS_SUCCESS)
99 {
100+ if (blurred)
101+ cairo_surface_destroy (blurred);
102 cairo_surface_destroy (normal);
103 return;
104 }
105@@ -782,8 +802,11 @@
106 normal = cairo_image_surface_create (CAIRO_FORMAT_RGB24,
107 width,
108 height);
109- if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS)
110+ if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) {
111+ if (normal)
112+ cairo_surface_destroy (normal);
113 return;
114+ }
115 }
116
117 // use tile for top-left background-part to fill the full bg-surface
118@@ -795,6 +818,8 @@
119 {
120 cairo_surface_destroy (normal);
121 cairo_surface_destroy (blurred);
122+ if (cr)
123+ cairo_destroy (cr);
124 return;
125 }
126
127@@ -1957,6 +1982,8 @@
128 priv->timer_id = 0;
129 }
130
131+ bubble_del ( (Bubble*) gobject);
132+
133 // chain up to the parent class
134 G_OBJECT_CLASS (bubble_parent_class)->finalize (gobject);
135 }
136@@ -2177,7 +2204,7 @@
137 return GET_PRIVATE (self)->sender;
138 }
139
140-void
141+static void
142 bubble_del (Bubble* self)
143 {
144 BubblePrivate* priv;
145@@ -2199,8 +2226,6 @@
146 tile_destroy (priv->tile_body);
147 if (priv->tile_indicator)
148 tile_destroy (priv->tile_indicator);
149-
150- g_object_unref (self);
151 }
152
153 void
154@@ -2972,13 +2997,19 @@
155 priv = GET_PRIVATE (self);
156
157 surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1);
158- if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS)
159+ if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
160+ if (surface)
161+ cairo_surface_destroy (surface);
162 return 0;
163+ }
164
165 cr = cairo_create (surface);
166 cairo_surface_destroy (surface);
167- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
168+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
169+ if (cr)
170+ cairo_destroy (cr);
171 return 0;
172+ }
173
174 layout = pango_cairo_create_layout (cr);
175 desc = pango_font_description_new ();
176@@ -3044,8 +3075,11 @@
177 priv = GET_PRIVATE (self);
178
179 cr = gdk_cairo_create (priv->widget->window);
180- if (cairo_status (cr) != CAIRO_STATUS_SUCCESS)
181+ if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
182+ if (cr)
183+ cairo_destroy (cr);
184 return 0;
185+ }
186
187 layout = pango_cairo_create_layout (cr);
188 desc = pango_font_description_new ();
189
190=== modified file 'src/bubble.h'
191--- src/bubble.h 2009-07-21 11:29:03 +0000
192+++ src/bubble.h 2009-07-31 11:06:13 +0000
193@@ -95,9 +95,6 @@
194 bubble_get_sender (Bubble *self);
195
196 void
197-bubble_del (Bubble* self);
198-
199-void
200 bubble_set_title (Bubble* self,
201 const gchar* title);
202
203
204=== modified file 'src/stack.c'
205--- src/stack.c 2009-07-23 16:00:55 +0000
206+++ src/stack.c 2009-07-31 10:46:09 +0000
207@@ -361,6 +361,17 @@
208 {
209 g_object_unref (n);
210 sync_bubble = NULL;
211+ } if (IS_BUBBLE (n)) {
212+ stack_pop_bubble_by_id (stack, bubble_get_id ((Bubble*) n));
213+ /* Fix for a tricky race condition
214+ where a bubble fades out in sync
215+ with a synchronous bubble: the symc.
216+ one is still considered visible while
217+ the normal one has triggered this signal.
218+ This ensures the display slot of the
219+ sync. bubble is recycled, and no gap is
220+ left on the screen */
221+ sync_bubble = NULL;
222 } else {
223 /* Fix for a tricky race condition
224 where a bubble fades out in sync
225
226=== modified file 'src/tile.c'
227--- src/tile.c 2009-07-16 20:38:59 +0000
228+++ src/tile.c 2009-07-31 11:07:29 +0000
229@@ -114,21 +114,14 @@
230 void
231 tile_destroy (tile_t* tile)
232 {
233- gpointer data;
234-
235 if (!tile)
236 return;
237
238 //cairo_surface_write_to_png (tile->priv->normal, "./tile-normal.png");
239 //cairo_surface_write_to_png (tile->priv->blurred, "./tile-blurred.png");
240
241- data = (gpointer) cairo_image_surface_get_data (tile->priv->normal);
242- g_free (data);
243- cairo_surface_destroy (tile->priv->normal);
244-
245- data = (gpointer) cairo_image_surface_get_data (tile->priv->blurred);
246- g_free (data);
247- cairo_surface_destroy (tile->priv->blurred);
248+ destroy_cloned_surface (tile->priv->normal);
249+ destroy_cloned_surface (tile->priv->blurred);
250
251 g_free ((gpointer) tile->priv);
252 g_free ((gpointer) tile);
253@@ -254,8 +247,11 @@
254 if (normal_alpha > 0.0f)
255 {
256 pattern = cairo_pattern_create_for_surface (tile->priv->normal);
257- if (cairo_pattern_status (pattern) != CAIRO_STATUS_SUCCESS)
258+ if (cairo_pattern_status (pattern) != CAIRO_STATUS_SUCCESS) {
259+ if (pattern)
260+ cairo_pattern_destroy (pattern);
261 return;
262+ }
263
264 cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
265 cairo_set_source (cr, pattern);
266@@ -276,8 +272,11 @@
267 if (blurred_alpha > 0.0f)
268 {
269 pattern = cairo_pattern_create_for_surface (tile->priv->blurred);
270- if (cairo_pattern_status (pattern) != CAIRO_STATUS_SUCCESS)
271+ if (cairo_pattern_status (pattern) != CAIRO_STATUS_SUCCESS) {
272+ if (pattern)
273+ cairo_pattern_destroy (pattern);
274 return;
275+ }
276
277 cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
278 cairo_set_source (cr, pattern);
279
280=== modified file 'src/util.c'
281--- src/util.c 2009-07-16 20:38:59 +0000
282+++ src/util.c 2009-07-31 11:11:30 +0000
283@@ -110,6 +110,20 @@
284 return text6;
285 }
286
287+gboolean
288+destroy_cloned_surface (cairo_surface_t* surface)
289+{
290+ gboolean finalref = FALSE;
291+ g_return_val_if_fail (surface, FALSE);
292+
293+ if (cairo_surface_get_reference_count (surface) == 1) {
294+ g_free (cairo_image_surface_get_data (surface));
295+ finalref = TRUE;
296+ }
297+ cairo_surface_destroy (surface);
298+ return finalref;
299+}
300+
301 cairo_surface_t*
302 copy_surface (cairo_surface_t* orig)
303 {
304
305=== modified file 'src/util.h'
306--- src/util.h 2009-07-16 20:38:59 +0000
307+++ src/util.h 2009-07-31 10:43:39 +0000
308@@ -34,3 +34,7 @@
309
310 cairo_surface_t*
311 copy_surface (cairo_surface_t* orig);
312+
313+gboolean
314+destroy_cloned_surface (cairo_surface_t* surface);
315+
316
317=== modified file 'tests/test-i18n.c'
318--- tests/test-i18n.c 2009-03-19 14:52:08 +0000
319+++ tests/test-i18n.c 2009-07-31 11:06:13 +0000
320@@ -116,7 +116,7 @@
321 bubble_move (bubble, 30, 30); \
322 bubble_show (bubble); \
323 wait_a_little (1000); \
324- bubble_del (bubble); \
325+ g_object_unref (G_OBJECT(bubble)); \
326 defaults_del (defaults); \
327 }
328

Subscribers

People subscribed via source and target branches