void gnm_shutdown (void) { GSList *plugin_states; gnm_app_clipboard_clear (TRUE); plugin_states = go_plugins_shutdown (); if (NULL != plugin_states) { gnm_conf_set_plugins_file_states (plugin_states); g_slist_free_full (plugin_states, g_free); } stf_shutdown (); gnm_xml_sax_write_shutdown (); gnm_xml_sax_read_shutdown (); gnm_autofill_shutdown (); print_shutdown (); gnm_func_shutdown_ (); gnm_rendered_value_shutdown (); dependent_types_shutdown (); gui_clipboard_shutdown (); clipboard_shutdown (); gnm_sheet_cell_shutdown (); gnm_expr_deriv_shutdown_ (); gnm_expr_shutdown_ (); parse_util_shutdown (); value_shutdown (); // The style leak printer may access font/border/color info so // shut styles down first. gnm_style_shutdown (); gnm_font_shutdown (); gnm_border_shutdown (); gnm_color_shutdown (); gnm_conf_shutdown (); _gnm_unregister_resource (); libgoffice_shutdown (); go_plugin_services_shutdown (); g_object_unref (gnm_app_get_app ()); gutils_shutdown (); }
int main (int argc, const char **argv) { #ifdef WIN32 { // set the console to accept escape sequences (Win10+) HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); if (console != INVALID_HANDLE_VALUE) { DWORD consoleMode = 0; GetConsoleMode(console, &consoleMode); consoleMode |= 4; // ENABLE_VIRTUAL_TERMINAL_PROCESSING; but that isn't available in our current SDK target SetConsoleMode(console, consoleMode); } } #endif int exit_code = EXIT_SUCCESS; try { // Experiment with floating point masks. // #ifdef FE_NOMASK_ENV // feenableexcept(FE_INVALID); // feenableexcept(FE_DIVBYZERO | FE_INVALID); // #endif bgl = new BackgroundLoader(); size_t winid = gfx_init(cb); debug_drawer = new BulletDebugDrawer(ogre_sm); // FIXME: hack #ifdef WIN32 mouse = new MouseDirectInput8(winid); bool use_dinput = getenv("GRIT_DINPUT")!=NULL; keyboard = use_dinput ? (Keyboard *)new KeyboardDirectInput8(winid) : (Keyboard *)new KeyboardWinAPI(winid); #else mouse = new MouseX11(winid); keyboard = new KeyboardX11(winid); #endif clipboard_init(); physics_init(); net_init(); core_option_init(); streamer_init(); navigation_init(); // audio_init(getenv("GRIT_AUDIO_DEV")); audio_init(NULL); std::vector<std::string> args; for (int i=0 ; i<argc ; i++) { args.push_back(argv[i]); } try { const char *init_file = getenv("GRIT_INIT"); if (init_file == nullptr) init_file = "/system/init.lua"; init_lua(init_file, args, core_L); } catch (Exception &e) { CERR << "Fatal error: " << e << std::endl; exit_code = EXIT_FAILURE; } // Lua returns - we quit. CVERB << "Shutting down Lua net subsystem..." << std::endl; net_shutdown(core_L); navigation_shutdown(); object_all_del(core_L); // Will remove all demands from background loader. CVERB << "Shutting down Lua graphics subsystem..." << std::endl; gfx_shutdown_lua(core_L); CVERB << "Shutting down Background Loader..." << std::endl; bgl->shutdown(); CVERB << "Shutting down Mouse & Keyboard..." << std::endl; if (mouse) delete mouse; if (keyboard) delete keyboard; CVERB << "Shutting down clipboard..." << std::endl; clipboard_shutdown(); CVERB << "Shutting down Lua VM..." << std::endl; if (core_L) shutdown_lua(core_L); CVERB << "Shutting down audio subsystem..." << std::endl; audio_shutdown(); //close AL device CVERB << "Shutting down physics subsystem..." << std::endl; physics_shutdown(); CVERB << "Shutting down the physics debug drawer..." << std::endl; if (debug_drawer) delete debug_drawer; CVERB << "Shutting down the Graphics subsystem..." << std::endl; gfx_shutdown(); delete bgl; } catch (Exception &e) { std::cerr << "TOP LEVEL ERROR: " << e << std::endl; return EXIT_FAILURE; } return exit_code; }