{ NULL, 0, 0, 0, NULL, NULL, NULL }
};
+ /* Enable threads before anything else, to prevent memory corruption */
+ if (!g_thread_supported())
+ g_thread_init(NULL);
+ gdk_threads_init ();
+
context = g_option_context_new (NULL);
g_option_context_add_main_entries (context, options, NULL);
}
g_option_context_free (context);
- if (!modest_init_init_core ()) {
+ if (!modest_init_init_core (argc, argv)) {
g_printerr ("modest: cannot init modest core\n");
return MODEST_ERR_INIT;
-
}
account_or_default = check_account (account);
g_free (account);
if (!batch) {
+ gdk_threads_enter ();
if (!modest_init_init_ui (argc, argv)) {
g_printerr ("modest: cannot init modest ui\n");
retval = MODEST_ERR_UI;
+ gdk_threads_leave ();
goto cleanup;
} else {
GtkWidget *ui = NULL;
retval = start_ui (account_or_default,
mailto, cc, bcc, subject, body, &ui);
- if (ui)
+ if (G_IS_OBJECT(ui))
g_signal_connect (G_OBJECT (ui), "show", G_CALLBACK(on_show), NULL);
}
} else {
gtk_widget_show_all (GTK_WIDGET (win));
gtk_main();
+ gdk_threads_leave ();
return MODEST_ERR_NONE;
}