From 2f8f9e570328c3e806e71f9df15c7dc921acd19a Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Thu, 20 Sep 2007 13:25:01 +0000 Subject: [PATCH] * handle the case when init fails more gracefully (not Criticals) * remove some needless debug stuff pmo-trunk-r3371 --- src/modest-init.c | 29 +++++++++++++++++------------ src/modest-main.c | 3 --- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/modest-init.c b/src/modest-init.c index 690f7c8..d0cc3e2 100644 --- a/src/modest-init.c +++ b/src/modest-init.c @@ -63,6 +63,9 @@ static void init_default_settings (ModestConf *conf); static void init_device_name (ModestConf *conf); static gboolean init_ui (gint argc, gchar** argv); + +static gboolean _is_initialized = FALSE; + /* * defaults for the column headers */ @@ -122,7 +125,8 @@ static const TnyFolderType LOCAL_FOLDERS[] = { }; #endif /* MODEST_PLATFORM_MAEMO */ -static GList* new_cold_ids_gslist_from_array( const FolderCols* cols, guint col_num) +static GList* +new_cold_ids_gslist_from_array( const FolderCols* cols, guint col_num) { GList *result = NULL; @@ -177,15 +181,12 @@ gboolean modest_init (int argc, char *argv[]) { gboolean reset; - static gboolean invoked = FALSE; - if (invoked) { + if (_is_initialized) { g_printerr ("modest: modest_init_init_core may only be invoked once\n"); - g_assert (!invoked); /* abort */ return FALSE; - } else - invoked = TRUE; - + } + init_i18n(); init_debug_g_type(); init_debug_logging(); @@ -241,8 +242,8 @@ modest_init (int argc, char *argv[]) g_printerr ("modest: failed to init ui\n"); return FALSE; } - - return TRUE; + + return _is_initialized = TRUE; } @@ -267,12 +268,16 @@ init_ui (gint argc, gchar** argv) gboolean modest_init_uninit (void) { + if (!_is_initialized) + return TRUE; + + if (gnome_vfs_initialized()) /* apparently, this returns TRUE, even after a shutdown */ + gnome_vfs_shutdown (); + if (!modest_runtime_uninit()) g_printerr ("modest: failed to uninit runtime\n"); - if (gnome_vfs_initialized()) - gnome_vfs_shutdown (); - + _is_initialized = FALSE; return TRUE; } diff --git a/src/modest-main.c b/src/modest-main.c index 52ad08b..498fc4d 100644 --- a/src/modest-main.c +++ b/src/modest-main.c @@ -45,7 +45,6 @@ main (int argc, char *argv[]) * command line.: */ gboolean show_ui_without_top_application_method = FALSE; if (argc >= 2) { - printf ("DEBUG: %s: argv[1]=%s\n", __FUNCTION__, argv[1]); if (strcmp (argv[1], "showui") == 0) show_ui_without_top_application_method = TRUE; } @@ -100,8 +99,6 @@ cleanup: retval = 1; } - g_debug ("closing modest with retval %d", retval); - return retval; } -- 1.7.9.5