/* open_default will make function reload default session files on close */ void project_close(gboolean open_default) { GSList *node; g_return_if_fail(app->project != NULL); ui_set_statusbar(TRUE, _("Project \"%s\" closed."), app->project->name); /* use write_config() to save project session files */ if (!write_config(FALSE)) g_warning("Project file \"%s\" could not be written", app->project->file_name); /* remove project filetypes build entries */ if (app->project->build_filetypes_list != NULL) { g_ptr_array_foreach(app->project->build_filetypes_list, remove_foreach_project_filetype, NULL); g_ptr_array_free(app->project->build_filetypes_list, FALSE); } /* remove project non filetype build menu items */ build_remove_menu_item(GEANY_BCS_PROJ, GEANY_GBG_NON_FT, -1); build_remove_menu_item(GEANY_BCS_PROJ, GEANY_GBG_EXEC, -1); g_free(app->project->name); g_free(app->project->description); g_free(app->project->file_name); g_free(app->project->base_path); g_free(app->project); app->project = NULL; foreach_slist(node, stash_groups) stash_group_free(node->data); g_slist_free(stash_groups); stash_groups = NULL; apply_editor_prefs(); /* ensure that global settings are restored */ if (project_prefs.project_session) { /* close all existing tabs first */ document_close_all(); /* after closing all tabs let's open the tabs found in the default config */ if (open_default && cl_options.load_session) { configuration_reload_default_session(); configuration_open_files(); /* open a new file if no other file was opened */ document_new_file_if_non_open(); ui_focus_current_document(); } } g_signal_emit_by_name(geany_object, "project-close"); update_ui(); }
void project_finalize(void) { stash_group_free(indent_group); }