[gmime] Don't register an atexit() handler



commit 700d99126a27aa06efaff6391db4fc31b8f19d82
Author: Jeffrey Stedfast <fejj gnome org>
Date:   Fri Mar 26 09:15:43 2010 -0400

    Don't register an atexit() handler
    
    2010-03-26  Jeffrey Stedfast  <fejj novell com>
    
    	Fixes for bug #613653
    
    	* gmime/gmime.c (g_mime_init): Initialize GMimeObject's type
    	registry.
    	(g_mime_shutdown): Shut it down here.
    
    	* gmime/gmime-object.c (g_mime_object_type_registry_init):
    	* Renamed
    	a bit and fixed to not use g_atexit(). Also made
    internal-public.
    	(g_mime_object_type_registry_shutdown): Renamed and made
    	internal-public.
    	(g_mime_object_register_type): Don't init the type system
    anymore.
    	(g_mime_object_new): Same.
    	(g_mime_object_new_type): Same here.

 ChangeLog            |   18 ++++++++++++++++++
 gmime/gmime-object.c |   20 ++++----------------
 gmime/gmime-object.h |    4 ++++
 gmime/gmime.c        |    2 ++
 4 files changed, 28 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 890f2a2..47c8865 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2010-03-26  Jeffrey Stedfast  <fejj novell com>
 
+	Fixes for bug #613653
+
+	* gmime/gmime.c (g_mime_init): Initialize GMimeObject's type
+	registry.
+	(g_mime_shutdown): Shut it down here.
+
+	* gmime/gmime-object.c (g_mime_object_type_registry_init): Renamed
+	a bit and fixed to not use g_atexit(). Also made internal-public.
+	(g_mime_object_type_registry_shutdown): Renamed and made
+	internal-public.
+	(g_mime_object_register_type): Don't init the type system anymore.
+	(g_mime_object_new): Same.
+	(g_mime_object_new_type): Same here.
+
+2010-03-26  Jeffrey Stedfast  <fejj novell com>
+
+	Fixes for bug #598855
+
 	* gmime/gmime-message.c (process_header): Return TRUE if we match
 	MIME-Version.
 	(message_prepend_header): Don't drop MIME-Version headers.
diff --git a/gmime/gmime-object.c b/gmime/gmime-object.c
index ca17f10..de94ed1 100644
--- a/gmime/gmime-object.c
+++ b/gmime/gmime-object.c
@@ -78,8 +78,6 @@ static ssize_t write_disposition (GMimeStream *stream, const char *name, const c
 static void content_type_changed (GMimeContentType *content_type, gpointer args, GMimeObject *object);
 static void content_disposition_changed (GMimeContentDisposition *disposition, gpointer args, GMimeObject *object);
 
-static void type_registry_init (void);
-
 
 static GHashTable *type_hash = NULL;
 
@@ -130,8 +128,6 @@ g_mime_object_class_init (GMimeObjectClass *klass)
 	klass->get_headers = object_get_headers;
 	klass->write_to_stream = object_write_to_stream;
 	klass->encode = object_encode;
-	
-	type_registry_init ();
 }
 
 static void
@@ -279,8 +275,6 @@ g_mime_object_register_type (const char *type, const char *subtype, GType object
 	g_return_if_fail (subtype != NULL);
 	g_return_if_fail (type != NULL);
 	
-	type_registry_init ();
-	
 	if (!(bucket = g_hash_table_lookup (type_hash, type))) {
 		bucket = g_new (struct _type_bucket, 1);
 		bucket->type = g_strdup (type);
@@ -321,8 +315,6 @@ g_mime_object_new (GMimeContentType *content_type)
 	
 	g_return_val_if_fail (GMIME_IS_CONTENT_TYPE (content_type), NULL);
 	
-	type_registry_init ();
-	
 	if ((bucket = g_hash_table_lookup (type_hash, content_type->type))) {
 		if (!(sub = g_hash_table_lookup (bucket->subtype_hash, content_type->subtype)))
 			sub = g_hash_table_lookup (bucket->subtype_hash, "*");
@@ -376,8 +368,6 @@ g_mime_object_new_type (const char *type, const char *subtype)
 	
 	g_return_val_if_fail (type != NULL, NULL);
 	
-	type_registry_init ();
-	
 	if ((bucket = g_hash_table_lookup (type_hash, type))) {
 		if (!(sub = g_hash_table_lookup (bucket->subtype_hash, subtype)))
 			sub = g_hash_table_lookup (bucket->subtype_hash, "*");
@@ -1079,20 +1069,18 @@ type_bucket_foreach (gpointer key, gpointer value, gpointer user_data)
 	g_free (bucket);
 }
 
-static void
-type_registry_shutdown (void)
+void
+g_mime_object_type_registry_shutdown (void)
 {
 	g_hash_table_foreach (type_hash, type_bucket_foreach, NULL);
 	g_hash_table_destroy (type_hash);
 }
 
-static void
-type_registry_init (void)
+void
+g_mime_object_type_registry_init (void)
 {
 	if (type_hash)
 		return;
 	
 	type_hash = g_hash_table_new (g_mime_strcase_hash, g_mime_strcase_equal);
-	
-	g_atexit (type_registry_shutdown);
 }
diff --git a/gmime/gmime-object.h b/gmime/gmime-object.h
index 8624270..5f1ea5d 100644
--- a/gmime/gmime-object.h
+++ b/gmime/gmime-object.h
@@ -133,6 +133,10 @@ char *g_mime_object_to_string (GMimeObject *object);
 
 void g_mime_object_encode (GMimeObject *object, GMimeEncodingConstraint constraint);
 
+/* Internal API */
+G_GNUC_INTERNAL void g_mime_object_type_registry_init (void);
+G_GNUC_INTERNAL void g_mime_object_type_registry_shutdown (void);
+
 G_END_DECLS
 
 #endif /* __GMIME_OBJECT_H__ */
diff --git a/gmime/gmime.c b/gmime/gmime.c
index 4800dd5..454ea16 100644
--- a/gmime/gmime.c
+++ b/gmime/gmime.c
@@ -121,6 +121,7 @@ g_mime_init (guint32 flags)
 	internet_address_mailbox_get_type ();
 	
 	/* register our default mime object types */
+	g_mime_object_type_registry_init ();
 	g_mime_object_register_type ("*", "*", g_mime_part_get_type ());
 	g_mime_object_register_type ("multipart", "*", g_mime_multipart_get_type ());
 	g_mime_object_register_type ("multipart", "encrypted", g_mime_multipart_encrypted_get_type ());
@@ -144,6 +145,7 @@ g_mime_shutdown (void)
 	if (--initialized)
 		return;
 	
+	g_mime_object_type_registry_shutdown ();
 	g_mime_charset_map_shutdown ();
 	g_mime_iconv_shutdown ();
 }



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