From 60f3e852e7246e3107b80cfa72a76e0c50753ede Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 16 Mar 2012 13:47:20 +0100 Subject: Bug #665130 - Memory leaks in Preferences and ETable --- widgets/misc/e-preferences-window.c | 4 ++++ widgets/table/e-table.c | 1 - widgets/table/gal-a11y-e-table-item.c | 19 +++++++++++++++++-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/widgets/misc/e-preferences-window.c b/widgets/misc/e-preferences-window.c index 3bce24371e..986d66f206 100644 --- a/widgets/misc/e-preferences-window.c +++ b/widgets/misc/e-preferences-window.c @@ -556,6 +556,10 @@ e_preferences_window_setup (EPreferencesWindow *window) g_return_if_fail (E_IS_PREFERENCES_WINDOW (window)); priv = E_PREFERENCES_WINDOW_GET_PRIVATE (window); + + if (priv->setup) + return; + notebook = GTK_NOTEBOOK (priv->notebook); num = gtk_notebook_get_n_pages (notebook); diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 50751c8889..aab26439af 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -1754,7 +1754,6 @@ et_real_construct (ETable *e_table, e_table->draw_focus = specification->draw_focus; e_table->cursor_mode = specification->cursor_mode; e_table->full_header = e_table_spec_to_full_header (specification, ete); - g_object_ref (e_table->full_header); col_count = e_table_header_count (e_table->full_header); for (i = 0; i < col_count; i++) { diff --git a/widgets/table/gal-a11y-e-table-item.c b/widgets/table/gal-a11y-e-table-item.c index 2c6de549b9..ea9c12b1d7 100644 --- a/widgets/table/gal-a11y-e-table-item.c +++ b/widgets/table/gal-a11y-e-table-item.c @@ -71,6 +71,21 @@ static gboolean gal_a11y_e_table_item_unref_selection (GalA11yETableItem *a11y); static AtkObject * eti_ref_at (AtkTable *table, gint row, gint column); +static void +free_columns (ETableCol **columns) +{ + gint ii; + + if (!columns) + return; + + for (ii = 0; columns[ii]; ii++) { + g_object_unref (columns[ii]); + } + + g_free (columns); +} + static void item_finalized (gpointer user_data, GObject *gone_item) @@ -219,7 +234,7 @@ eti_dispose (GObject *object) GalA11yETableItemPrivate *priv = GET_PRIVATE (a11y); if (priv->columns) { - g_free (priv->columns); + free_columns (priv->columns); priv->columns = NULL; } @@ -934,7 +949,7 @@ eti_header_structure_changed (ETableHeader *eth, g_free (reorder); g_free (prev_state); - g_free (priv->columns); + free_columns (priv->columns); priv->columns = cols; } -- cgit v1.2.3