[gnumeric] xml-sax: unregister opener and saver on shutdown.



commit 699e0b89e9eeffd798c8dcbabb034e83ec80ab22
Author: Morten Welinder <terra gnome org>
Date:   Tue Oct 13 22:11:39 2009 -0400

    xml-sax: unregister opener and saver on shutdown.

 ChangeLog           |    9 +++++++++
 src/libgnumeric.c   |    2 ++
 src/xml-sax-read.c  |   22 +++++++++++++++++-----
 src/xml-sax-write.c |   11 ++++++++++-
 src/xml-sax.h       |    3 +++
 5 files changed, 41 insertions(+), 6 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f7a1c4b..cf3af44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2009-10-13  Morten Welinder  <terra gnome org>
 
+	* src/libgnumeric.c (gnm_shutdown): Call gnm_xml_sax_read_shutdown
+	and gnm_xml_sax_write_shutdown.
+
+	* src/xml-sax-read.c (gnm_xml_sax_read_init): Plug leak.
+	(gnm_xml_sax_read_shutdown): New function.
+
+	* src/xml-sax-write.c (gnm_xml_sax_write_init): Plug leak.
+	(gnm_xml_sax_write_shutdown): New function.
+
 	* src/sheet-object-widget.c (sheet_widget_adjustment_get_horizontal):
 	New function.
 	(sheet_widget_list_base_get_content_link): Rename from
diff --git a/src/libgnumeric.c b/src/libgnumeric.c
index 1a85e2c..ef3f477 100644
--- a/src/libgnumeric.c
+++ b/src/libgnumeric.c
@@ -321,6 +321,8 @@ gnm_shutdown (void)
 	}
 
 	stf_shutdown ();
+	gnm_xml_sax_write_shutdown ();
+	gnm_xml_sax_read_shutdown ();
 
 	gnm_autofill_shutdown ();
 	print_shutdown ();
diff --git a/src/xml-sax-read.c b/src/xml-sax-read.c
index ddac01c..014422d 100644
--- a/src/xml-sax-read.c
+++ b/src/xml-sax-read.c
@@ -3101,18 +3101,30 @@ xml_probe (GOFileOpener const *fo, GsfInput *input, GOFileProbeLevel pl)
 	return gsf_xml_probe (input, &gnm_xml_probe_element);
 }
 
+#define XML_SAX_ID "Gnumeric_XmlIO:sax"
+
 void
 gnm_xml_sax_read_init (void)
 {
+	GOFileOpener *opener;
 	GSList *suffixes = go_slist_create (g_strdup ("gnumeric"),
 					    g_strdup ("xml"),
 					    NULL);
 	GSList *mimes = go_slist_create (g_strdup ("application/x-gnumeric"),
 					 NULL);
 
-	go_file_opener_register (go_file_opener_new (
-		"Gnumeric_XmlIO:sax",
-		_("Gnumeric XML (*.gnumeric)"),
-		suffixes, mimes,
-		xml_probe, gnm_xml_file_open), 50);
+	opener = go_file_opener_new
+		(XML_SAX_ID,
+		 _("Gnumeric XML (*.gnumeric)"),
+		 suffixes, mimes,
+		 xml_probe, gnm_xml_file_open);
+	go_file_opener_register (opener, 50);
+	g_object_unref (opener);
+}
+
+void
+gnm_xml_sax_read_shutdown (void)
+{
+	go_file_opener_unregister
+		(go_file_opener_for_id (XML_SAX_ID));
 }
diff --git a/src/xml-sax-write.c b/src/xml-sax-write.c
index 45aaa2a..7abf989 100644
--- a/src/xml-sax-write.c
+++ b/src/xml-sax-write.c
@@ -1487,12 +1487,13 @@ gnm_cellregion_to_xml (GnmCellRegion const *cr)
 	return GSF_OUTPUT_MEMORY (buf);
 }
 
+#define XML_SAX_ID "Gnumeric_XmlIO:sax"
 
 void
 gnm_xml_sax_write_init (void)
 {
 	GOFileSaver *saver = go_file_saver_new
-		("Gnumeric_XmlIO:sax",
+		(XML_SAX_ID,
 		 "gnumeric",
 		 _("Gnumeric XML (*.gnumeric)"),
 		 GO_FILE_FL_AUTO, gnm_xml_file_save);
@@ -1501,4 +1502,12 @@ gnm_xml_sax_write_init (void)
 		      NULL);
 
 	go_file_saver_register_as_default (saver, 50);
+	g_object_unref (saver);
+}
+
+void
+gnm_xml_sax_write_shutdown (void)
+{
+	go_file_saver_unregister
+		(go_file_saver_for_id (XML_SAX_ID));
 }
diff --git a/src/xml-sax.h b/src/xml-sax.h
index e083dbb..51aecaa 100644
--- a/src/xml-sax.h
+++ b/src/xml-sax.h
@@ -37,7 +37,10 @@ void      gnm_xml_prep_style_parser (GsfXMLIn *xin,
 				     gpointer user);
 
 void      gnm_xml_sax_read_init (void);
+void      gnm_xml_sax_read_shutdown (void);
+
 void      gnm_xml_sax_write_init (void);
+void      gnm_xml_sax_write_shutdown (void);
 
 GnmConventions *gnm_xml_io_conventions (void);
 



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