[gmime/gmime-2-4] Don't register an atexit() handler
- From: Jeffrey Stedfast <fejj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gmime/gmime-2-4] Don't register an atexit() handler
- Date: Fri, 26 Mar 2010 13:12:19 +0000 (UTC)
commit 789f51119ed49f0c2f8ce44e4fc1b5c80c3d84d5
Author: Jeffrey Stedfast <fejj gnome org>
Date: Fri Mar 26 09:11:36 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, 27 insertions(+), 17 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b786f1c..b9a85da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,20 @@
-2010-02-06 Jeffrey Stedfast <fejj novell com>
+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>
* gmime/gmime-message.c (process_header): Return TRUE if we match
MIME-Version.
diff --git a/gmime/gmime-object.c b/gmime/gmime-object.c
index e46a474..be766f7 100644
--- a/gmime/gmime-object.c
+++ b/gmime/gmime-object.c
@@ -76,8 +76,6 @@ static ssize_t write_disposition (GMimeStream *stream, const char *name, const c
static void content_type_changed (GMimeContentType *content_type, GMimeObject *object);
static void content_disposition_changed (GMimeContentDisposition *disposition, GMimeObject *object);
-static void type_registry_init (void);
-
static GHashTable *type_hash = NULL;
@@ -127,8 +125,6 @@ g_mime_object_class_init (GMimeObjectClass *klass)
klass->set_content_type = set_content_type;
klass->get_headers = get_headers;
klass->write_to_stream = write_to_stream;
-
- type_registry_init ();
}
static void
@@ -280,8 +276,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);
@@ -322,8 +316,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, "*");
@@ -377,8 +369,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, "*");
@@ -1061,20 +1051,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 0c68a59..fb4ddd8 100644
--- a/gmime/gmime-object.h
+++ b/gmime/gmime-object.h
@@ -128,6 +128,10 @@ char *g_mime_object_get_headers (GMimeObject *object);
ssize_t g_mime_object_write_to_stream (GMimeObject *object, GMimeStream *stream);
char *g_mime_object_to_string (GMimeObject *object);
+/* 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 9e1c26d..7b8a171 100644
--- a/gmime/gmime.c
+++ b/gmime/gmime.c
@@ -119,6 +119,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 ());
@@ -142,6 +143,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]