diff options
author | Sam Spilsbury <sam.spilsbury@canonical.com> | 2011-02-21 20:55:51 +0800 |
---|---|---|
committer | Sam Spilsbury <sam.spilsbury@canonical.com> | 2011-02-21 20:55:51 +0800 |
commit | d10bd89e7ca542bd227281e81626adcaf65f9adb (patch) | |
tree | 1ea9743443b9b33ce6c20e4976d158ff794fa403 /gtk/window-decorator | |
parent | 04c7585cd31d4b1ccd9be175ff9f296bad41598e (diff) | |
download | compiz-with-glib-mainloop-d10bd89e7ca542bd227281e81626adcaf65f9adb.tar.gz compiz-with-glib-mainloop-d10bd89e7ca542bd227281e81626adcaf65f9adb.tar.bz2 |
Fix memory leaks
- Use gtk_main_quit ();
- Don't create gconf clients where we don't need to
Diffstat (limited to 'gtk/window-decorator')
-rw-r--r-- | gtk/window-decorator/events.c | 2 | ||||
-rw-r--r-- | gtk/window-decorator/frames.c | 39 | ||||
-rw-r--r-- | gtk/window-decorator/gtk-window-decorator.c | 21 | ||||
-rw-r--r-- | gtk/window-decorator/gtk-window-decorator.h | 8 | ||||
-rw-r--r-- | gtk/window-decorator/settings.c | 3 | ||||
-rw-r--r-- | gtk/window-decorator/switcher.c | 26 | ||||
-rw-r--r-- | gtk/window-decorator/wnck.c | 4 |
7 files changed, 83 insertions, 20 deletions
diff --git a/gtk/window-decorator/events.c b/gtk/window-decorator/events.c index 6bbad04..1dea221 100644 --- a/gtk/window-decorator/events.c +++ b/gtk/window-decorator/events.c @@ -1163,7 +1163,7 @@ selection_event_filter_func (GdkXEvent *gdkxevent, case SelectionClear: status = decor_handle_selection_clear (xdisplay, xevent, 0); if (status == DECOR_SELECTION_GIVE_UP) - exit (0); + gtk_main_quit (); default: break; } diff --git a/gtk/window-decorator/frames.c b/gtk/window-decorator/frames.c index 40c4e04..c735e7b 100644 --- a/gtk/window-decorator/frames.c +++ b/gtk/window-decorator/frames.c @@ -43,18 +43,7 @@ decor_frame_refresh (decor_frame_t *frame) /* Should really read gconf for that */ - gchar *str = NULL; - -#ifdef USE_GCONF - - GConfClient *client = gconf_client_get_default (); - - str = gconf_client_get_string (client, - COMPIZ_TITLEBAR_FONT_KEY, - NULL); -#endif - if (!str) - str = g_strdup ("Sans Bold 12"); + gchar *str = settings->font; set_frame_scale (frame, str); @@ -281,6 +270,32 @@ decor_frame_new (const gchar *type) void decor_frame_destroy (decor_frame_t *frame) { + Display *xdisplay = gdk_x11_get_default_xdisplay (); + + if (frame->border_shadow) + decor_shadow_destroy (xdisplay, frame->border_shadow); + + if (frame->border_no_shadow) + decor_shadow_destroy (xdisplay, frame->border_no_shadow); + + if (frame->max_border_shadow) + decor_shadow_destroy (xdisplay, frame->max_border_shadow); + + if (frame->max_border_no_shadow) + decor_shadow_destroy (xdisplay, frame->max_border_no_shadow); + + if (frame->style_window_rgba) + gtk_widget_destroy (GTK_WIDGET (frame->style_window_rgba)); + + if (frame->style_window_rgb) + gtk_widget_destroy (GTK_WIDGET (frame->style_window_rgb)); + + if (frame->pango_context) + g_object_unref (G_OBJECT (frame->pango_context)); + + if (frame->titlebar_font) + pango_font_description_free (frame->titlebar_font); + if (frame) free (frame->type); diff --git a/gtk/window-decorator/gtk-window-decorator.c b/gtk/window-decorator/gtk-window-decorator.c index 526e989..545c7ed 100644 --- a/gtk/window-decorator/gtk-window-decorator.c +++ b/gtk/window-decorator/gtk-window-decorator.c @@ -120,6 +120,7 @@ main (int argc, char *argv[]) unsigned int nchildren; Window root_ret, parent_ret; Window *children = NULL; + GList *windows, *win; decor_frame_t *default_p, *bare_p, *switcher_p; #ifdef USE_METACITY @@ -406,6 +407,26 @@ main (int argc, char *argv[]) gtk_main (); + win = windows = wnck_screen_get_windows (screen); + + while (win != NULL) + { + WnckWindow *w = (WnckWindow *) win->data; + + window_closed (screen, w); + } + + g_list_free (windows); + + if (screen) + g_object_unref (screen); + + if (tip_window) + gtk_widget_destroy (GTK_WIDGET (tip_window)); + + if (tip_label) + gtk_widget_destroy (GTK_WIDGET (tip_label)); + gwd_decor_frame_unref (default_p); gwd_decor_frame_unref (bare_p); gwd_decor_frame_unref (switcher_p); diff --git a/gtk/window-decorator/gtk-window-decorator.h b/gtk/window-decorator/gtk-window-decorator.h index f6b1c44..4e973e7 100644 --- a/gtk/window-decorator/gtk-window-decorator.h +++ b/gtk/window-decorator/gtk-window-decorator.h @@ -641,6 +641,14 @@ void connect_screen (WnckScreen *screen); void +window_opened (WnckScreen *screen, + WnckWindow *window); + +void +window_closed (WnckScreen *screen, + WnckWindow *window); + +void add_frame_window (WnckWindow *win, Window frame, Bool mode); diff --git a/gtk/window-decorator/settings.c b/gtk/window-decorator/settings.c index ccc1361..3934554 100644 --- a/gtk/window-decorator/settings.c +++ b/gtk/window-decorator/settings.c @@ -363,7 +363,8 @@ titlebar_font_changed (GConfClient *client) gwd_frames_foreach (set_frames_scales, (gpointer) settings->font); - g_free (str); + if (str) + g_free (str); } static void diff --git a/gtk/window-decorator/switcher.c b/gtk/window-decorator/switcher.c index 177e4c3..1aec3b1 100644 --- a/gtk/window-decorator/switcher.c +++ b/gtk/window-decorator/switcher.c @@ -63,6 +63,7 @@ create_switcher_frame (const gchar *type) void destroy_switcher_frame (decor_frame_t *frame) { + gtk_widget_destroy (switcher_label); decor_frame_destroy (frame); } @@ -244,10 +245,6 @@ draw_switcher_background (decor_t *d) cairo_destroy (cr); - GdkPixbuf *buf = gdk_pixbuf_get_from_drawable (NULL, d->buffer_pixmap, NULL, 0, 0, 0, 0, d->width, d->height); - - gdk_pixbuf_save (buf, "/home/smspillaz/rendered_switcher.png", "png", NULL, NULL); - copy_to_front_buffer (d); pixel = ((((a * style->bg[GTK_STATE_NORMAL].blue ) >> 24) & 0x0000ff) | @@ -330,6 +327,27 @@ draw_switcher_decoration (decor_t *d) void switcher_window_closed () { + decor_t *d = switcher_window; + Display *xdisplay = gdk_x11_get_default_xdisplay (); + + if (d->layout) + g_object_unref (G_OBJECT (d->layout)); + + if (d->name) + g_free (d->name); + + if (d->pixmap) + g_object_unref (G_OBJECT (d->pixmap)); + + if (d->buffer_pixmap) + g_object_unref (G_OBJECT (d->buffer_pixmap)); + + if (d->cr) + cairo_destroy (d->cr); + + if (d->picture) + XRenderFreePicture (xdisplay, d->picture); + gwd_decor_frame_unref (switcher_window->frame); g_free (switcher_window); switcher_window = NULL; diff --git a/gtk/window-decorator/wnck.c b/gtk/window-decorator/wnck.c index 1c962e6..96d2113 100644 --- a/gtk/window-decorator/wnck.c +++ b/gtk/window-decorator/wnck.c @@ -571,7 +571,7 @@ active_window_changed (WnckScreen *screen) } } -static void +void window_opened (WnckScreen *screen, WnckWindow *win) { @@ -637,7 +637,7 @@ window_opened (WnckScreen *screen, } } -static void +void window_closed (WnckScreen *screen, WnckWindow *win) { |