[gnumeric] Leaks: plug leaks releated to workbook_sheets.



commit 9385a38b310336c57d6f364ca5d6eddac2b34b23
Author: Morten Welinder <terra gnome org>
Date:   Sun May 22 14:01:41 2011 -0400

    Leaks: plug leaks releated to workbook_sheets.

 NEWS                                  |    1 +
 plugins/openoffice/ChangeLog          |    5 +++
 plugins/openoffice/openoffice-read.c  |    6 +++-
 plugins/openoffice/openoffice-write.c |    6 +++-
 src/dialogs/ChangeLog                 |    4 +++
 src/dialogs/dialog-define-names.c     |   48 +++++++++++++++------------------
 6 files changed, 40 insertions(+), 30 deletions(-)
---
diff --git a/NEWS b/NEWS
index 3429466..6a0dd1e 100644
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,7 @@ Gnumeric 1.10.16
 Morten:
 	* Fix leaks in SHEET.  [#650761]
 	* Fix leaks in SHEETS.  [#650764]
+	* Fix leak in name dialog.
 
 --------------------------------------------------------------------------
 Gnumeric 1.10.15
diff --git a/plugins/openoffice/ChangeLog b/plugins/openoffice/ChangeLog
index 7f272f0..7d59d6e 100644
--- a/plugins/openoffice/ChangeLog
+++ b/plugins/openoffice/ChangeLog
@@ -1,5 +1,10 @@
 2011-05-22  Morten Welinder  <terra gnome org>
 
+	* openoffice-write.c (odf_write_ooo_settings): Plug leak.
+
+	* openoffice-read.c (openoffice_file_open): Plug leak during
+	debug.
+
 	* openoffice-write.c (odf_write_content): Remove test for
 	always-true condition.  If we must have that check, it should
 	check for an active global name that we intend to write.
diff --git a/plugins/openoffice/openoffice-read.c b/plugins/openoffice/openoffice-read.c
index 86ce192..1b69bc5 100644
--- a/plugins/openoffice/openoffice-read.c
+++ b/plugins/openoffice/openoffice-read.c
@@ -9171,17 +9171,19 @@ openoffice_file_open (GOFileOpener const *fo, GOIOContext *io_context,
 		state.sheet_order = g_slist_reverse (state.sheet_order);
 
 		if (state.debug) {
-			GSList *l;
+			GSList *l, *sheets;
 			g_printerr ("Order we desire:\n");
 			for (l = state.sheet_order; l; l = l->next) {
 				Sheet *sheet = l->data;
 				g_printerr ("Sheet %s\n", sheet->name_unquoted);
 			}
 			g_printerr ("Order we have:\n");
-			for (l = workbook_sheets (state.pos.wb); l; l = l->next) {
+			sheets = workbook_sheets (state.pos.wb);
+			for (l = sheets; l; l = l->next) {
 				Sheet *sheet = l->data;
 				g_printerr ("Sheet %s\n", sheet->name_unquoted);
 			}
+			g_slist_free (sheets);
 		}
 
 		workbook_sheet_reorder (state.pos.wb, state.sheet_order);
diff --git a/plugins/openoffice/openoffice-write.c b/plugins/openoffice/openoffice-write.c
index 48d27d3..a58791b 100644
--- a/plugins/openoffice/openoffice-write.c
+++ b/plugins/openoffice/openoffice-write.c
@@ -4717,7 +4717,7 @@ odf_write_gnm_settings (GnmOOExport *state)
 static void
 odf_write_ooo_settings (GnmOOExport *state)
 {
-	GSList *l;
+	GSList *l, *sheets;
 
 	gsf_xml_out_start_element (state->xml, CONFIG "config-item-set");
 	gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "name", OOO "view-settings");
@@ -4734,7 +4734,8 @@ odf_write_ooo_settings (GnmOOExport *state)
 	gsf_xml_out_add_cstr_unchecked (state->xml, CONFIG "name",
 				        "Tables");
 
-	for (l = workbook_sheets (state->wb); l != NULL; l = l->next) {
+	sheets = workbook_sheets (state->wb);
+	for (l = sheets; l != NULL; l = l->next) {
 		Sheet *sheet = l->data;
 		gsf_xml_out_start_element (state->xml, CONFIG "config-item-map-entry");
 		gsf_xml_out_add_cstr (state->xml, CONFIG "name", sheet->name_unquoted);
@@ -4753,6 +4754,7 @@ odf_write_ooo_settings (GnmOOExport *state)
 
 		gsf_xml_out_end_element (state->xml); /* </config:config-item-map-entry> */
 	}
+	g_slist_free (sheets);
 
 	gsf_xml_out_end_element (state->xml); /* </config:config-item-map-named> */
 	gsf_xml_out_end_element (state->xml); /* </config:config-item-map-entry> */
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 5a60439..341eeac 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,3 +1,7 @@
+2011-05-22  Morten Welinder  <terra gnome org>
+
+	* dialog-define-names.c (name_guru_populate_list): Plug leak.
+
 2011-05-21  Morten Welinder <terra gnome org>
 
 	* Release 1.10.15
diff --git a/src/dialogs/dialog-define-names.c b/src/dialogs/dialog-define-names.c
index 10389d4..291beff 100644
--- a/src/dialogs/dialog-define-names.c
+++ b/src/dialogs/dialog-define-names.c
@@ -279,8 +279,7 @@ name_guru_get_available_sheet_names (Sheet const *sheet)
 {
 	GList *res = NULL;
 
-	gnm_sheet_foreach_name (sheet, (GHFunc) cb_get_names,
-				&res);
+	gnm_sheet_foreach_name (sheet, (GHFunc) cb_get_names, &res);
 	return g_list_sort (res, (GCompareFunc)expr_name_cmp_by_name);
 }
 
@@ -390,7 +389,6 @@ static void
 name_guru_populate_list (NameGuruState *state)
 {
 	GtkTreeIter	 iter;
-	GSList          *sheets;
 
 	g_return_if_fail (state != NULL);
 	g_return_if_fail (state->treeview != NULL);
@@ -433,29 +431,27 @@ name_guru_populate_list (NameGuruState *state)
 		       item_type_available_sheet_name);
 	name_guru_expand_at_iter (state, &iter);
 
-	for (sheets = workbook_sheets (state->wb);
-	     sheets != NULL;
-	     sheets = sheets->next) {
-		Sheet *sheet = sheets->data;
-
-		if (sheet == state->sheet)
-			continue;
-
-		gtk_tree_store_append (state->model, &iter, NULL);
-		gtk_tree_store_set (state->model, &iter,
-				    ITEM_NAME, sheet->name_unquoted,
-				    ITEM_NAME_POINTER, sheet,
-				    ITEM_TYPE, item_type_other_sheet,
-				    ITEM_CONTENT_IS_EDITABLE, FALSE,
-				    ITEM_NAME_IS_EDITABLE, FALSE,
-				    ITEM_VISIBLE, TRUE,
-				    ITEM_PASTABLE, FALSE,
-				    -1);
-
-		name_guru_store_names
-			(name_guru_get_available_sheet_names (sheet),
-			 &iter, state, item_type_foreign_name);
-	}
+	WORKBOOK_FOREACH_SHEET
+		(state->wb, sheet,
+		 {
+			 if (sheet == state->sheet)
+				 continue;
+
+			 gtk_tree_store_append (state->model, &iter, NULL);
+			 gtk_tree_store_set (state->model, &iter,
+					     ITEM_NAME, sheet->name_unquoted,
+					     ITEM_NAME_POINTER, sheet,
+					     ITEM_TYPE, item_type_other_sheet,
+					     ITEM_CONTENT_IS_EDITABLE, FALSE,
+					     ITEM_NAME_IS_EDITABLE, FALSE,
+					     ITEM_VISIBLE, TRUE,
+					     ITEM_PASTABLE, FALSE,
+					     -1);
+
+			 name_guru_store_names
+				 (name_guru_get_available_sheet_names (sheet),
+				  &iter, state, item_type_foreign_name);
+		 });
 }
 
 static gboolean



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]