diff --git a/ChangeLog b/ChangeLog index fd4a6d0bb2..9da691c2c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2002-11-17 Christian Stimming + + * src/import-export/hbci/gnc-hbci-utils.c: Fix caching of HBCI_API + when using multiple files one after another. + 2002-11-17 Matthew Vanecek * src/backend/postgres/putil.c: Added needed header files to the c file. diff --git a/src/import-export/hbci/Makefile.am b/src/import-export/hbci/Makefile.am index 7e9c983acb..bfab2a51b8 100644 --- a/src/import-export/hbci/Makefile.am +++ b/src/import-export/hbci/Makefile.am @@ -52,6 +52,7 @@ AM_CFLAGS = \ -I${top_srcdir}/src/import-export \ -I${top_srcdir}/src/register \ -I${top_srcdir}/src/register/register-core \ + -I${top_srcdir}/src/register/register-gnome \ -I${top_srcdir}/src/register/ledger-core \ ${G_WRAP_COMPILE_ARGS} \ ${GUILE_INCS} \ diff --git a/src/import-export/hbci/gnc-hbci-utils.c b/src/import-export/hbci/gnc-hbci-utils.c index 3767b6da7d..6360828ec8 100644 --- a/src/import-export/hbci/gnc-hbci-utils.c +++ b/src/import-export/hbci/gnc-hbci-utils.c @@ -74,17 +74,29 @@ gnc_hbci_api_new (const char *filename, gboolean allowNewFile, }; static HBCI_API *gnc_hbci_api = NULL; +static char *gnc_hbci_configfile = NULL; static GNCInteractor *gnc_hbci_inter = NULL; HBCI_API * gnc_hbci_api_new_currentbook (GtkWidget *parent, GNCInteractor **inter) { if (gnc_hbci_api == NULL) { - gnc_hbci_api = gnc_hbci_api_new - (gnc_hbci_get_book_configfile (gnc_get_current_book ()), - FALSE, parent, inter); + /* No API cached -- create new one. */ + gnc_hbci_configfile = + g_strdup (gnc_hbci_get_book_configfile (gnc_get_current_book ())); + gnc_hbci_api = gnc_hbci_api_new (gnc_hbci_configfile, + FALSE, parent, inter); gnc_hbci_inter = *inter; + } else if ((gnc_hbci_configfile != NULL) && + (strcmp(gnc_hbci_configfile, + gnc_hbci_get_book_configfile (gnc_get_current_book ())) + != 0)) { + /* Wrong API cached -- delete old and create new. */ + gnc_hbci_api_delete (gnc_hbci_api); + printf("gnc_hbci_api_new_currentbook: Wrong HBCI_API cached; creating new one.\n"); + return gnc_hbci_api_new_currentbook (parent, inter); } + /* Correct API cached. */ *inter = gnc_hbci_inter; return gnc_hbci_api; }; @@ -94,6 +106,8 @@ void gnc_hbci_api_delete (HBCI_API *api) if (api == gnc_hbci_api) { gnc_hbci_api = NULL; gnc_hbci_inter = NULL; + g_free (gnc_hbci_configfile); + gnc_hbci_configfile = NULL; } HBCI_API_delete (api); }