From 23c1d1a5980951c1fd3079d02391cf3cbca9b018 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20K=C3=B6hler?= Date: Sat, 12 May 2007 23:30:35 +0000 Subject: [PATCH] Add gnc_history_remove_file, call it if the history file cannot be loaded, #388500. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16077 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/bin/gnucash-bin.c | 3 +- src/gnome-utils/gnc-plugin-file-history.c | 41 ++++++++++++++++++++++- src/gnome-utils/gnc-plugin-file-history.h | 7 ++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/src/bin/gnucash-bin.c b/src/bin/gnucash-bin.c index 3674c5d8e0..db739e821a 100644 --- a/src/bin/gnucash-bin.c +++ b/src/bin/gnucash-bin.c @@ -471,7 +471,8 @@ inner_main (void *closure, int argc, char **argv) if (!nofile && (fn = get_file_to_load())) { gnc_update_splash_screen(_("Loading data...")); gnc_destroy_splash_screen(); - gnc_file_open_file(fn); + if (!gnc_file_open_file(fn)) + gnc_history_remove_file(fn); g_free(fn); } else if (gnc_gconf_get_bool("dialogs/new_user", "first_startup", &error) diff --git a/src/gnome-utils/gnc-plugin-file-history.c b/src/gnome-utils/gnc-plugin-file-history.c index bf028f4494..8fc1a1d260 100644 --- a/src/gnome-utils/gnc-plugin-file-history.c +++ b/src/gnome-utils/gnc-plugin-file-history.c @@ -206,6 +206,43 @@ gnc_history_add_file (const char *newfile) } +/** Remove all occurences of a file name from the history list. Move + * the other key values up in the list to fill the gaps. + * + * @param filename The name of the file to remove from the list. + */ +void +gnc_history_remove_file (const char *oldfile) +{ + gchar *filename, *from, *to; + gint i, j; + + if (!oldfile) + return; + if (!g_utf8_validate(oldfile, -1, NULL)) + return; + + for (i=0, j=0; iwindow)); - gnc_file_open_file (filename); /* also opens new account page */ + /* also opens new account page */ + if (!gnc_file_open_file (filename)) + gnc_history_remove_file (filename); gnc_window_set_progressbar_window (NULL); } diff --git a/src/gnome-utils/gnc-plugin-file-history.h b/src/gnome-utils/gnc-plugin-file-history.h index 3a16b464a7..90532189b0 100644 --- a/src/gnome-utils/gnc-plugin-file-history.h +++ b/src/gnome-utils/gnc-plugin-file-history.h @@ -93,6 +93,13 @@ GncPlugin *gnc_plugin_file_history_new (void); */ void gnc_history_add_file (const char *filename); +/** Remove all occurences of a file name from the history list. Move + * the other key values up in the list to fill the gaps. + * + * @param filename The name of the file to remove from the list. + */ +void gnc_history_remove_file (const char *filename); + /** Retrieve the name of the file most recently accessed. This is the * name at the front of the list. Since the "list" is actually a