[gnumeric] Fix leak.



commit 1390c5f1f4ed041692813e2da9ec9ed7d5b5c135
Author: Morten Welinder <terra gnome org>
Date:   Mon Sep 19 11:59:51 2011 -0400

    Fix leak.

 ChangeLog              |    5 +++++
 NEWS                   |    1 +
 src/main-application.c |   31 ++++++++++++++++++-------------
 3 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3cde5a7..50981bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2011-09-19  Morten Welinder  <terra gnome org>
+
+	* src/main-application.c (main): Fix handling of command context,
+	thus fixing leak.
+
 2011-09-13  Morten Welinder  <terra gnome org>
 
 	* src/number-match.c (format_match_datetime): Make sure
diff --git a/NEWS b/NEWS
index 9b8b2bd..48f8943 100644
--- a/NEWS
+++ b/NEWS
@@ -33,6 +33,7 @@ Jean:
 Morten:
 	* Fix crash.  [#658140]
 	* Fix stf import crash.  [#658982]
+	* Fix leaks.
 
 Valek:
 	* In xls import, set LABEL encoding based on FONT charset converted to 
diff --git a/src/main-application.c b/src/main-application.c
index 5eb0b01..49807d2 100644
--- a/src/main-application.c
+++ b/src/main-application.c
@@ -301,12 +301,22 @@ main (int argc, char const **argv)
 
 	gnm_init ();
 
+	/* These are useful for the build process only.  */
+	if (func_state_file)
+		return gnm_dump_func_defs (func_state_file, 0);
+	if (func_def_file)
+		return gnm_dump_func_defs (func_def_file, 1);
+	if (split_funcdocs)
+		return gnm_dump_func_defs (NULL, 2);
+	if (ext_refs_file)
+		return gnm_dump_func_defs (ext_refs_file, 4);
+
 	if (with_gui) {
 		cc = g_object_new (GO_TYPE_IO_CONTEXT_GTK,
-				       "show-splash", !gnumeric_no_splash,
-				       "show-warnings", !gnumeric_no_warnings,
-				       NULL);
-		ioc = GO_IO_CONTEXT (cc);
+				   "show-splash", !gnumeric_no_splash,
+				   "show-warnings", !gnumeric_no_warnings,
+				   NULL);
+		ioc = GO_IO_CONTEXT (g_object_ref (cc));
 		handle_paint_events ();
 		pathetic_qt_workaround ();
 	} else {
@@ -316,15 +326,6 @@ main (int argc, char const **argv)
 	}
 	go_component_set_command_context (cc);
 
-	if (func_state_file)
-		return gnm_dump_func_defs (func_state_file, 0);
-	if (func_def_file)
-		return gnm_dump_func_defs (func_def_file, 1);
-	if (split_funcdocs)
-		return gnm_dump_func_defs (NULL, 2);
-	if (ext_refs_file)
-		return gnm_dump_func_defs (ext_refs_file, 4);
-
 	/* Keep in sync with .desktop file */
 	g_set_application_name (_("Gnumeric Spreadsheet"));
 	gnm_plugins_init (GO_CMD_CONTEXT (ioc));
@@ -418,6 +419,10 @@ main (int argc, char const **argv)
 	store_plugin_state ();
 	gnm_shutdown ();
 
+	go_component_set_command_context (NULL);
+	g_object_unref (cc);
+	cc = NULL;
+
 #if defined(G_OS_WIN32)
 	if (has_console) {
 		close(1);



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