[PATCH] lib: call g_type_init from notmuch_database_open

David Bremner david at tethera.net
Sun Dec 4 11:35:14 PST 2011


From: David Bremner <bremner at debian.org>

We want to make sure g_type_init is called before any GObject
functionality is used.
---
This seems to fix the segfault for me. Any other comments/experiences?

 lib/database.cc |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/lib/database.cc b/lib/database.cc
index e4ef14e..98f101e 100644
--- a/lib/database.cc
+++ b/lib/database.cc
@@ -26,6 +26,7 @@
 #include <signal.h>
 
 #include <glib.h> /* g_free, GPtrArray, GHashTable */
+#include <glib-object.h> /* g_type_init */
 
 using namespace std;
 
@@ -600,6 +601,9 @@ notmuch_database_open (const char *path,
 	goto DONE;
     }
 
+    /* Initialize the GLib type system and threads */
+    g_type_init ();
+
     notmuch = talloc (NULL, notmuch_database_t);
     notmuch->exception_reported = FALSE;
     notmuch->path = talloc_strdup (notmuch, path);
-- 
1.7.7.3



More information about the notmuch mailing list