Merge lp:~agateau/notify-osd/fix-valgrind-errors into lp:notify-osd/trunk
- fix-valgrind-errors
- Merge into main
Proposed by
Aurélien Gâteau
Status: | Merged |
---|---|
Approved by: | Mirco Müller |
Approved revision: | 400 |
Merged at revision: | not available |
Proposed branch: | lp:~agateau/notify-osd/fix-valgrind-errors |
Merge into: | lp:notify-osd/trunk |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~agateau/notify-osd/fix-valgrind-errors |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mirco Müller (community) | Approve | ||
Review via email: mp+12153@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Aurélien Gâteau (agateau) wrote : | # |
- 399. By Aurélien Gâteau
-
Was about to unref the instance returned by g_file_
new_for_ path()
when I noticed this would be even simpler - 400. By Aurélien Gâteau
-
Comment is not relevant anymore
Revision history for this message
Mirco Müller (macslow) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/bubble.c' |
2 | --- src/bubble.c 2009-08-27 09:52:34 +0000 |
3 | +++ src/bubble.c 2009-09-21 10:18:17 +0000 |
4 | @@ -475,41 +475,6 @@ |
5 | cairo_surface_destroy (new_surface); |
6 | } |
7 | |
8 | -cairo_surface_t* |
9 | -_copy_surface (cairo_surface_t* orig) |
10 | -{ |
11 | - cairo_surface_t* copy = NULL; |
12 | - guchar* pixels_src = NULL; |
13 | - guchar* pixels_cpy = NULL; |
14 | - cairo_format_t format; |
15 | - gint width; |
16 | - gint height; |
17 | - gint stride; |
18 | - |
19 | - pixels_src = cairo_image_surface_get_data (orig); |
20 | - if (!pixels_src) |
21 | - return NULL; |
22 | - |
23 | - format = cairo_image_surface_get_format (orig); |
24 | - width = cairo_image_surface_get_width (orig); |
25 | - height = cairo_image_surface_get_height (orig); |
26 | - stride = cairo_image_surface_get_stride (orig); |
27 | - |
28 | - pixels_cpy = g_malloc0 (stride * height); |
29 | - if (!pixels_cpy) |
30 | - return NULL; |
31 | - |
32 | - memcpy ((void*) pixels_cpy, (void*) pixels_src, height * stride); |
33 | - |
34 | - copy = cairo_image_surface_create_for_data (pixels_cpy, |
35 | - format, |
36 | - width, |
37 | - height, |
38 | - stride); |
39 | - |
40 | - return copy; |
41 | -} |
42 | - |
43 | static void |
44 | _draw_layout_grid (cairo_t* cr, |
45 | Bubble* bubble) |
46 | @@ -665,9 +630,11 @@ |
47 | |
48 | g_return_if_fail (scratch); |
49 | |
50 | - if (cairo_surface_status (scratch) != CAIRO_STATUS_SUCCESS) { |
51 | + if (cairo_surface_status (scratch) != CAIRO_STATUS_SUCCESS) |
52 | + { |
53 | if (scratch) |
54 | cairo_surface_destroy (scratch); |
55 | + |
56 | return; |
57 | } |
58 | |
59 | @@ -676,8 +643,10 @@ |
60 | if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) |
61 | { |
62 | cairo_surface_destroy (scratch); |
63 | + |
64 | if (cr) |
65 | cairo_destroy (cr); |
66 | + |
67 | return; |
68 | } |
69 | |
70 | @@ -766,7 +735,7 @@ |
71 | cairo_image_surface_get_stride (clone)); |
72 | blurred = copy_surface (dummy); |
73 | cairo_surface_destroy (dummy); |
74 | - cairo_surface_destroy (clone); |
75 | + destroy_cloned_surface (clone); |
76 | |
77 | // finally create tile with top-left shadow/background part |
78 | if (priv->tile_background_part) |
79 | @@ -782,9 +751,13 @@ |
80 | normal = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, |
81 | width, |
82 | height); |
83 | - if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) { |
84 | + if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) |
85 | + { |
86 | + cairo_surface_destroy (scratch); |
87 | + |
88 | if (normal) |
89 | cairo_surface_destroy (normal); |
90 | + |
91 | return; |
92 | } |
93 | |
94 | @@ -793,9 +766,12 @@ |
95 | height); |
96 | if (cairo_surface_status (blurred) != CAIRO_STATUS_SUCCESS) |
97 | { |
98 | + cairo_surface_destroy (normal); |
99 | + cairo_surface_destroy (scratch); |
100 | + |
101 | if (blurred) |
102 | cairo_surface_destroy (blurred); |
103 | - cairo_surface_destroy (normal); |
104 | + |
105 | return; |
106 | } |
107 | } |
108 | @@ -805,9 +781,13 @@ |
109 | normal = cairo_image_surface_create (CAIRO_FORMAT_RGB24, |
110 | width, |
111 | height); |
112 | - if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) { |
113 | + if (cairo_surface_status (normal) != CAIRO_STATUS_SUCCESS) |
114 | + { |
115 | + cairo_surface_destroy (scratch); |
116 | + |
117 | if (normal) |
118 | cairo_surface_destroy (normal); |
119 | + |
120 | return; |
121 | } |
122 | } |
123 | @@ -821,8 +801,11 @@ |
124 | { |
125 | cairo_surface_destroy (normal); |
126 | cairo_surface_destroy (blurred); |
127 | + cairo_surface_destroy (scratch); |
128 | + |
129 | if (cr) |
130 | cairo_destroy (cr); |
131 | + |
132 | return; |
133 | } |
134 | |
135 | @@ -851,6 +834,7 @@ |
136 | if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) |
137 | { |
138 | cairo_surface_destroy (normal); |
139 | + cairo_surface_destroy (scratch); |
140 | |
141 | if (priv->composited) |
142 | cairo_surface_destroy (blurred); |
143 | @@ -890,6 +874,7 @@ |
144 | cairo_surface_destroy (blurred); |
145 | |
146 | cairo_surface_destroy (normal); |
147 | + cairo_surface_destroy (scratch); |
148 | } |
149 | |
150 | void |
151 | @@ -947,13 +932,14 @@ |
152 | void |
153 | _refresh_title (Bubble* self) |
154 | { |
155 | - BubblePrivate* priv = GET_PRIVATE (self); |
156 | - Defaults* d = self->defaults; |
157 | - cairo_surface_t* normal = NULL; |
158 | - cairo_t* cr = NULL; |
159 | - PangoFontDescription* desc = NULL; |
160 | - PangoLayout* layout = NULL; |
161 | - raico_blur_t* blur = NULL; |
162 | + BubblePrivate* priv = GET_PRIVATE (self); |
163 | + Defaults* d = self->defaults; |
164 | + cairo_surface_t* normal = NULL; |
165 | + cairo_t* cr = NULL; |
166 | + PangoFontDescription* desc = NULL; |
167 | + PangoLayout* layout = NULL; |
168 | + raico_blur_t* blur = NULL; |
169 | + gchar* text_font_face = NULL; |
170 | |
171 | // create temp. scratch surface |
172 | normal = cairo_image_surface_create ( |
173 | @@ -986,13 +972,14 @@ |
174 | defaults_get_text_title_size (d) * |
175 | PANGO_SCALE); |
176 | |
177 | - pango_font_description_set_family_static (desc, |
178 | - defaults_get_text_font_face (d)); |
179 | + text_font_face = defaults_get_text_font_face (d); |
180 | + pango_font_description_set_family_static (desc, text_font_face); |
181 | pango_font_description_set_weight (desc, |
182 | defaults_get_text_title_weight (d)); |
183 | pango_font_description_set_style (desc, PANGO_STYLE_NORMAL); |
184 | pango_layout_set_font_description (layout, desc); |
185 | pango_font_description_free (desc); |
186 | + g_free ((gpointer) text_font_face); |
187 | |
188 | pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR); |
189 | pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); |
190 | @@ -1051,13 +1038,14 @@ |
191 | void |
192 | _refresh_body (Bubble* self) |
193 | { |
194 | - BubblePrivate* priv = GET_PRIVATE (self); |
195 | - Defaults* d = self->defaults; |
196 | - cairo_surface_t* normal = NULL; |
197 | - cairo_t* cr = NULL; |
198 | - PangoFontDescription* desc = NULL; |
199 | - PangoLayout* layout = NULL; |
200 | - raico_blur_t* blur = NULL; |
201 | + BubblePrivate* priv = GET_PRIVATE (self); |
202 | + Defaults* d = self->defaults; |
203 | + cairo_surface_t* normal = NULL; |
204 | + cairo_t* cr = NULL; |
205 | + PangoFontDescription* desc = NULL; |
206 | + PangoLayout* layout = NULL; |
207 | + raico_blur_t* blur = NULL; |
208 | + gchar* text_font_face = NULL; |
209 | |
210 | // create temp. scratch surface |
211 | normal = cairo_image_surface_create ( |
212 | @@ -1090,13 +1078,14 @@ |
213 | defaults_get_text_body_size (d) * |
214 | PANGO_SCALE); |
215 | |
216 | - pango_font_description_set_family_static (desc, |
217 | - defaults_get_text_font_face (d)); |
218 | + text_font_face = defaults_get_text_font_face (d); |
219 | + pango_font_description_set_family_static (desc, text_font_face); |
220 | pango_font_description_set_weight (desc, |
221 | defaults_get_text_body_weight (d)); |
222 | pango_font_description_set_style (desc, PANGO_STYLE_NORMAL); |
223 | pango_layout_set_font_description (layout, desc); |
224 | pango_font_description_free (desc); |
225 | + g_free ((gpointer) text_font_face); |
226 | |
227 | pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR); |
228 | pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); |
229 | @@ -3049,6 +3038,7 @@ |
230 | PangoRectangle log_rect = {0, 0, 0, 0}; |
231 | gint title_height; |
232 | BubblePrivate* priv; |
233 | + gchar* text_font_face = NULL; |
234 | |
235 | if (!self || !IS_BUBBLE (self)) |
236 | return 0; |
237 | @@ -3089,9 +3079,8 @@ |
238 | defaults_get_text_title_size (d) * |
239 | PANGO_SCALE); |
240 | |
241 | - pango_font_description_set_family_static ( |
242 | - desc, |
243 | - defaults_get_text_font_face (d)); |
244 | + text_font_face = defaults_get_text_font_face (d); |
245 | + pango_font_description_set_family_static (desc, text_font_face); |
246 | |
247 | pango_font_description_set_weight ( |
248 | desc, |
249 | @@ -3100,6 +3089,7 @@ |
250 | pango_font_description_set_style (desc, PANGO_STYLE_NORMAL); |
251 | pango_layout_set_font_description (layout, desc); |
252 | pango_font_description_free (desc); |
253 | + g_free ((gpointer) text_font_face); |
254 | |
255 | pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END); |
256 | pango_layout_set_wrap (layout, PANGO_WRAP_WORD_CHAR); |
257 | @@ -3127,6 +3117,7 @@ |
258 | PangoRectangle log_rect; |
259 | gint body_height; |
260 | BubblePrivate* priv; |
261 | + gchar* text_font_face = NULL; |
262 | |
263 | if (!self || !IS_BUBBLE (self)) |
264 | return 0; |
265 | @@ -3159,9 +3150,8 @@ |
266 | defaults_get_text_body_size (d) * |
267 | PANGO_SCALE); |
268 | |
269 | - pango_font_description_set_family_static ( |
270 | - desc, |
271 | - defaults_get_text_font_face (d)); |
272 | + text_font_face = defaults_get_text_font_face (d); |
273 | + pango_font_description_set_family_static (desc, text_font_face); |
274 | |
275 | pango_font_description_set_weight ( |
276 | desc, |
277 | @@ -3222,6 +3212,7 @@ |
278 | body_height = PANGO_PIXELS (log_rect.height); |
279 | |
280 | pango_font_description_free (desc); |
281 | + g_free ((gpointer) text_font_face); |
282 | g_object_unref (layout); |
283 | cairo_destroy (cr); |
284 | |
285 | |
286 | === modified file 'src/defaults.c' |
287 | --- src/defaults.c 2009-09-16 12:33:40 +0000 |
288 | +++ src/defaults.c 2009-09-18 19:48:10 +0000 |
289 | @@ -179,15 +179,17 @@ |
290 | GString* font_face = NULL; |
291 | gdouble dpi = 0.0f; |
292 | gdouble pixels_per_em = 0; |
293 | + gchar* font_name = NULL; |
294 | |
295 | if (!IS_DEFAULTS (self)) |
296 | return; |
297 | |
298 | /* determine current system font-name/size */ |
299 | error = NULL; |
300 | - string = g_string_new (gconf_client_get_string (self->context, |
301 | - GCONF_UI_FONT_NAME, |
302 | - &error)); |
303 | + font_name = gconf_client_get_string (self->context, |
304 | + GCONF_UI_FONT_NAME, |
305 | + &error); |
306 | + string = g_string_new (font_name); |
307 | if (error) |
308 | { |
309 | /* if something went wrong, assume "Sans 10" and continue */ |
310 | @@ -197,6 +199,7 @@ |
311 | error->message); |
312 | g_error_free (error); |
313 | } |
314 | + g_free ((gpointer) font_name); |
315 | |
316 | /* extract font-family-name and font-size */ |
317 | scanner = g_scanner_new (NULL); |
318 | @@ -430,63 +433,6 @@ |
319 | g_signal_emit (defaults, g_defaults_signals[GRAVITY_CHANGED], 0); |
320 | } |
321 | |
322 | -static gdouble |
323 | -_get_average_char_width (Defaults* self) |
324 | -{ |
325 | - cairo_surface_t* surface; |
326 | - cairo_t* cr; |
327 | - PangoFontDescription* desc; |
328 | - PangoLayout* layout; |
329 | - PangoContext* context; |
330 | - PangoLanguage* language; |
331 | - PangoFontMetrics* metrics; |
332 | - gint char_width; |
333 | - |
334 | - if (!self || !IS_DEFAULTS (self)) |
335 | - return 0; |
336 | - |
337 | - surface = cairo_image_surface_create (CAIRO_FORMAT_A1, 1, 1); |
338 | - if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) |
339 | - return 0; |
340 | - |
341 | - cr = cairo_create (surface); |
342 | - cairo_surface_destroy (surface); |
343 | - if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) |
344 | - return 0; |
345 | - |
346 | - layout = pango_cairo_create_layout (cr); |
347 | - desc = pango_font_description_new (); |
348 | - pango_font_description_set_size ( |
349 | - desc, |
350 | - EM2PIXELS (defaults_get_text_title_size (self), self) * |
351 | - PANGO_SCALE); |
352 | - |
353 | - pango_font_description_set_family_static ( |
354 | - desc, |
355 | - defaults_get_text_font_face (self)); |
356 | - |
357 | - pango_font_description_set_weight ( |
358 | - desc, |
359 | - defaults_get_text_title_weight (self)); |
360 | - |
361 | - pango_font_description_set_style (desc, PANGO_STYLE_NORMAL); |
362 | - pango_layout_set_wrap (layout, PANGO_WRAP_WORD); |
363 | - pango_layout_set_font_description (layout, desc); |
364 | - |
365 | - context = pango_layout_get_context (layout); /* no need to unref */ |
366 | - language = pango_language_get_default (); /* no need to unref */ |
367 | - metrics = pango_context_get_metrics (context, desc, language); |
368 | - char_width = pango_font_metrics_get_approximate_char_width (metrics); |
369 | - |
370 | - /* clean up */ |
371 | - pango_font_metrics_unref (metrics); |
372 | - pango_font_description_free (desc); |
373 | - g_object_unref (layout); |
374 | - cairo_destroy (cr); |
375 | - |
376 | - return PIXELS2EM (char_width / PANGO_SCALE, self); |
377 | -} |
378 | - |
379 | void |
380 | defaults_refresh_screen_dimension_properties (Defaults *self) |
381 | { |
382 | @@ -562,9 +508,6 @@ |
383 | gdouble icon_size; |
384 | gdouble bubble_height; |
385 | gdouble new_bubble_height; |
386 | - gdouble bubble_width; |
387 | - gdouble new_bubble_width; |
388 | - gdouble average_char_width; |
389 | |
390 | self = DEFAULTS (gobject); |
391 | |
392 | @@ -605,31 +548,6 @@ |
393 | NULL); |
394 | } |
395 | |
396 | - /* correct the default bubble-width depending on the average width of a |
397 | - * character rendered in the default system-font at the default |
398 | - * font-size, |
399 | - * as default layout, we'll take the icon+title+body+message case, thus |
400 | - * seen from left to right we use: |
401 | - * |
402 | - * margin + icon_size + margin + 20 * avg_char_width + margin |
403 | - */ |
404 | - g_object_get (self, |
405 | - "bubble-width", |
406 | - &bubble_width, |
407 | - NULL); |
408 | - average_char_width = _get_average_char_width (self); |
409 | - |
410 | - new_bubble_width = 3.0f * margin_size + |
411 | - icon_size + |
412 | - 20.0f * average_char_width; |
413 | - /*if (new_bubble_width > bubble_width) |
414 | - { |
415 | - g_object_set (self, |
416 | - "bubble-width", |
417 | - new_bubble_width, |
418 | - NULL); |
419 | - }*/ |
420 | - |
421 | /* FIXME: calling this here causes a segfault */ |
422 | /* chain up to the parent class */ |
423 | /*G_OBJECT_CLASS (defaults_parent_class)->constructed (gobject);*/ |
424 | @@ -2431,19 +2349,22 @@ |
425 | static gboolean |
426 | defaults_multihead_does_focus_follow (Defaults *self) |
427 | { |
428 | - GError *error = NULL; |
429 | - gboolean mode = FALSE; |
430 | + GError* error = NULL; |
431 | + gboolean mode = FALSE; |
432 | |
433 | g_return_val_if_fail (self != NULL && IS_DEFAULTS (self), FALSE); |
434 | |
435 | - gchar *mode_str = gconf_client_get_string (self->context, |
436 | + gchar* mode_str = gconf_client_get_string (self->context, |
437 | GCONF_MULTIHEAD_MODE, |
438 | &error); |
439 | if (mode_str != NULL) |
440 | { |
441 | if (! g_strcmp0 (mode_str, "focus-follow")) |
442 | mode = TRUE; |
443 | - } else if (error != NULL) |
444 | + |
445 | + g_free ((gpointer) mode_str); |
446 | + } |
447 | + else if (error != NULL) |
448 | { |
449 | g_warning ("defaults_multihead_does_focus_follow(): " |
450 | "Got error \"%s\"\n", |
Fix read after free reported by valgrind