mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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
This commit is contained in:
parent
12ec997301
commit
23c1d1a598
@ -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)
|
||||
|
@ -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; i<MAX_HISTORY_FILES; i++) {
|
||||
from = gnc_history_gconf_index_to_key(i);
|
||||
filename = gnc_gconf_get_string(HISTORY_STRING_SECTION, from, NULL);
|
||||
|
||||
if (filename) {
|
||||
if (g_utf8_collate(oldfile, filename) == 0) {
|
||||
gnc_gconf_unset(HISTORY_STRING_SECTION, from, NULL);
|
||||
} else {
|
||||
if (i != j) {
|
||||
to = gnc_history_gconf_index_to_key(j);
|
||||
gnc_gconf_set_string(HISTORY_STRING_SECTION, to, filename, NULL);
|
||||
gnc_gconf_unset(HISTORY_STRING_SECTION, from, NULL);
|
||||
g_free(to);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
g_free(from);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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
|
||||
* sequence of up to ten gconf keys, this is the value of key zero.
|
||||
@ -660,7 +697,9 @@ gnc_plugin_file_history_cmd_open_file (GtkAction *action,
|
||||
*/
|
||||
filename = g_object_get_data(G_OBJECT(action), FILENAME_STRING);
|
||||
gnc_window_set_progressbar_window (GNC_WINDOW(data->window));
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user