X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=blobdiff_plain;f=lib%2Fopen.cc;h=069c0664de35f0e3ae7364b3085c1c60c512310b;hp=7fc9a14ffbb8d9608eb2f55c319118b54afe89f2;hb=82aa3f4d2762cd56585369de5fa17cb50d77c85d;hpb=6251e2bb9ee023d25b58384c8a49576086fdaba3 diff --git a/lib/open.cc b/lib/open.cc index 7fc9a14f..069c0664 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -220,6 +220,24 @@ _set_database_path (notmuch_database_t *notmuch, _notmuch_config_cache (notmuch, NOTMUCH_CONFIG_DATABASE_PATH, path); } +static void +_init_libs () +{ + + static int initialized = 0; + + /* Initialize the GLib type system and threads */ +#if ! GLIB_CHECK_VERSION (2, 35, 1) + g_type_init (); +#endif + + /* Initialize gmime */ + if (! initialized) { + g_mime_init (); + initialized = 1; + } +} + notmuch_status_t notmuch_database_open_with_config (const char *database_path, notmuch_database_mode_t mode, @@ -237,7 +255,8 @@ notmuch_database_open_with_config (const char *database_path, int err; unsigned int version; GKeyFile *key_file = NULL; - static int initialized = 0; + + _init_libs (); notmuch = _alloc_notmuch (); if (! notmuch) { @@ -271,17 +290,6 @@ notmuch_database_open_with_config (const char *database_path, goto DONE; } - /* Initialize the GLib type system and threads */ -#if ! GLIB_CHECK_VERSION (2, 35, 1) - g_type_init (); -#endif - - /* Initialize gmime */ - if (! initialized) { - g_mime_init (); - initialized = 1; - } - try { std::string last_thread_id; std::string last_mod; @@ -467,6 +475,8 @@ notmuch_database_create_with_config (const char *database_path, int err; void *local = talloc_new (NULL); + _init_libs (); + if ((status = _choose_database_path (local, config_path, profile, &key_file, &database_path, &message))) goto DONE;