From 101305e1c7dc24f5a40e80a900b0777b2634722f Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Tue, 7 Sep 2010 18:39:46 +0200 Subject: Various memory leaks --- composer/e-composer-private.c | 25 +++++++++++++++---------- e-util/e-plugin-ui.c | 12 +++++++++--- e-util/e-plugin.c | 5 ----- em-format/em-format.c | 3 --- libgnomecanvas/gnome-canvas.c | 2 -- mail/em-format-html.c | 4 ++-- plugins/mail-notification/mail-notification.c | 1 + shell/e-shell-content.c | 5 +++++ shell/e-shell-searchbar.c | 5 +++++ shell/e-shell.c | 2 +- widgets/misc/e-menu-tool-button.c | 7 ++++++- widgets/text/e-text.c | 3 +++ 12 files changed, 47 insertions(+), 27 deletions(-) diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c index ed9e19096f..d4dcb46126 100644 --- a/composer/e-composer-private.c +++ b/composer/e-composer-private.c @@ -405,17 +405,22 @@ e_composer_private_constructed (EMsgComposer *composer) void e_composer_private_dispose (EMsgComposer *composer) { - GConfBridge *bridge; - GArray *array; - guint binding_id; - - bridge = gconf_bridge_get (); - array = composer->priv->gconf_bridge_binding_ids; + if (composer->priv->gconf_bridge_binding_ids) { + GConfBridge *bridge; + GArray *array; + guint binding_id; + + bridge = gconf_bridge_get (); + array = composer->priv->gconf_bridge_binding_ids; + + while (array->len > 0) { + binding_id = g_array_index (array, guint, 0); + gconf_bridge_unbind (bridge, binding_id); + g_array_remove_index_fast (array, 0); + } - while (array->len > 0) { - binding_id = g_array_index (array, guint, 0); - gconf_bridge_unbind (bridge, binding_id); - g_array_remove_index_fast (array, 0); + g_array_free (composer->priv->gconf_bridge_binding_ids, TRUE); + composer->priv->gconf_bridge_binding_ids = NULL; } if (composer->priv->shell != NULL) { diff --git a/e-util/e-plugin-ui.c b/e-util/e-plugin-ui.c index a03c6193ef..c79220be63 100644 --- a/e-util/e-plugin-ui.c +++ b/e-util/e-plugin-ui.c @@ -544,7 +544,7 @@ e_plugin_ui_register_manager (GtkUIManager *ui_manager, EPlugin *plugin = plugin_list->data; GSList *iter; - plugin_list = g_slist_next (plugin_list); + plugin_list = g_slist_remove (plugin_list, plugin); /* Look for hooks of type EPluginUIHook. */ for (iter = plugin->hooks; iter != NULL; iter = iter->next) { @@ -565,6 +565,8 @@ e_plugin_ui_register_manager (GtkUIManager *ui_manager, plugin_ui_hook_register_manager ( hook, ui_manager, id, user_data); } + + g_object_unref (plugin); } } @@ -583,7 +585,7 @@ e_plugin_ui_enable_manager (GtkUIManager *ui_manager, EPlugin *plugin = plugin_list->data; GSList *iter; - plugin_list = g_slist_next (plugin_list); + plugin_list = g_slist_remove (plugin_list, plugin); /* Look for hooks of type EPluginUIHook. */ for (iter = plugin->hooks; iter != NULL; iter = iter->next) { @@ -594,6 +596,8 @@ e_plugin_ui_enable_manager (GtkUIManager *ui_manager, plugin_ui_enable_manager (hook, ui_manager, id); } + + g_object_unref (plugin); } } @@ -612,7 +616,7 @@ e_plugin_ui_disable_manager (GtkUIManager *ui_manager, EPlugin *plugin = plugin_list->data; GSList *iter; - plugin_list = g_slist_next (plugin_list); + plugin_list = g_slist_remove (plugin_list, plugin); /* Look for hooks of type EPluginUIHook. */ for (iter = plugin->hooks; iter != NULL; iter = iter->next) { @@ -623,5 +627,7 @@ e_plugin_ui_disable_manager (GtkUIManager *ui_manager, plugin_ui_disable_manager (hook, ui_manager, id, TRUE); } + + g_object_unref (plugin); } } diff --git a/e-util/e-plugin.c b/e-util/e-plugin.c index 0da1151d21..db717e8dcd 100644 --- a/e-util/e-plugin.c +++ b/e-util/e-plugin.c @@ -83,9 +83,6 @@ struct _plugin_doc { gchar *filename; xmlDocPtr doc; - - GSList *plugin_hooks; /* EPlugin objects with pending hooks */ - GSList *plugins; /* xmlNodePtr's of plugins with unknown type (mono,etc) */ }; enum { @@ -359,7 +356,6 @@ ep_load_plugin (xmlNodePtr root, struct _plugin_doc *pdoc) pd(printf("Delaying loading of plugin '%s' unknown type '%s'\n", id, prop)); g_free (id); xmlFree (prop); - pdoc->plugins = g_slist_prepend (pdoc->plugins, root); return NULL; } xmlFree (prop); @@ -430,7 +426,6 @@ ep_load (const gchar *filename, gint load_level) ep->flags &= ~E_PLUGIN_FLAGS_SYSTEM_PLUGIN; g_free (is_system_plugin); - pdoc->plugin_hooks = g_slist_prepend (pdoc->plugin_hooks, ep); ep = NULL; } } diff --git a/em-format/em-format.c b/em-format/em-format.c index 0dd45effaa..119ac646a2 100644 --- a/em-format/em-format.c +++ b/em-format/em-format.c @@ -348,9 +348,6 @@ emf_class_init (EMFormatClass *class) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - class->type_handlers = g_hash_table_new (g_str_hash, g_str_equal); - emf_builtin_init (class); } static void diff --git a/libgnomecanvas/gnome-canvas.c b/libgnomecanvas/gnome-canvas.c index c335b9faa6..7188c77bcd 100644 --- a/libgnomecanvas/gnome-canvas.c +++ b/libgnomecanvas/gnome-canvas.c @@ -3226,8 +3226,6 @@ paint (GnomeCanvas *canvas) visible_rect.x1 = visible_rect.x0 + allocation.width; visible_rect.y1 = visible_rect.y0 + allocation.height; - region = gdk_region_new (); - for (i = 0; i < n_rects; i++) { ArtIRect clipped; diff --git a/mail/em-format-html.c b/mail/em-format-html.c index fb0bc0a567..8962de2c36 100644 --- a/mail/em-format-html.c +++ b/mail/em-format-html.c @@ -604,13 +604,13 @@ efh_finalize (GObject *object) { EMFormatHTML *efh = EM_FORMAT_HTML (object); - /* FIXME: check for leaked stuff */ - em_format_html_clear_pobject (efh); efh_gtkhtml_destroy (GTK_HTML (efh->priv->web_view), efh); g_hash_table_destroy (efh->priv->text_inline_parts); + g_mutex_free (efh->priv->lock); + /* Chain up to parent's finalize() method. */ G_OBJECT_CLASS (parent_class)->finalize (object); } diff --git a/plugins/mail-notification/mail-notification.c b/plugins/mail-notification/mail-notification.c index 5015e9c874..a75a522077 100644 --- a/plugins/mail-notification/mail-notification.c +++ b/plugins/mail-notification/mail-notification.c @@ -159,6 +159,7 @@ send_dbus_message (const gchar *name, #undef add_named_param g_dbus_message_set_body (message, g_variant_builder_end (builder)); + g_variant_builder_unref (builder); /* Sends the message */ g_dbus_connection_send_message ( diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c index 5173ee8c83..527ef250a6 100644 --- a/shell/e-shell-content.c +++ b/shell/e-shell-content.c @@ -142,6 +142,11 @@ shell_content_dispose (GObject *object) priv->shell_view = NULL; } + if (priv->user_filename) { + g_free (priv->user_filename); + priv->user_filename = NULL; + } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_shell_content_parent_class)->dispose (object); } diff --git a/shell/e-shell-searchbar.c b/shell/e-shell-searchbar.c index cb525f8f85..9a7800fdab 100644 --- a/shell/e-shell-searchbar.c +++ b/shell/e-shell-searchbar.c @@ -648,6 +648,11 @@ shell_searchbar_dispose (GObject *object) priv->search_option = NULL; } + if (priv->state_group) { + g_free (priv->state_group); + priv->state_group = NULL; + } + /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (e_shell_searchbar_parent_class)->dispose (object); } diff --git a/shell/e-shell.c b/shell/e-shell.c index db9efc9331..93832ec7fe 100644 --- a/shell/e-shell.c +++ b/shell/e-shell.c @@ -329,7 +329,7 @@ shell_ready_for_quit (EShell *shell, shell_ready_for_quit, shell); /* Finalize the activity. */ - g_object_ref (activity); + g_object_unref (activity); /* Destroy all watched windows. Note, we iterate over a -copy- * of the watched windows list because the act of destroying a diff --git a/widgets/misc/e-menu-tool-button.c b/widgets/misc/e-menu-tool-button.c index 7ca38bc1e9..612ed801f2 100644 --- a/widgets/misc/e-menu-tool-button.c +++ b/widgets/misc/e-menu-tool-button.c @@ -47,6 +47,7 @@ static GtkMenuItem * menu_tool_button_get_first_menu_item (GtkMenuToolButton *menu_tool_button) { GtkWidget *menu; + GtkMenuItem *item; GList *children; menu = gtk_menu_tool_button_get_menu (menu_tool_button); @@ -57,7 +58,11 @@ menu_tool_button_get_first_menu_item (GtkMenuToolButton *menu_tool_button) if (children == NULL) return NULL; - return GTK_MENU_ITEM (children->data); + item = GTK_MENU_ITEM (children->data); + + g_list_free (children); + + return item; } static void diff --git a/widgets/text/e-text.c b/widgets/text/e-text.c index 0383b00597..bb9b2dda51 100644 --- a/widgets/text/e-text.c +++ b/widgets/text/e-text.c @@ -429,6 +429,9 @@ reset_layout (EText *text) cairo_font_options_destroy (font_options); pango_layout_context_changed (text->layout); + if (text->font_desc) { + pango_font_description_free (text->font_desc); + } text->font_desc = pango_font_description_new (); if (!pango_font_description_get_size_is_absolute (style->font_desc)) pango_font_description_set_size (text->font_desc, -- cgit v1.2.3