Add aqbanking5 extensions of GWEN_GUI object.

We need to locally store a reference to that particular GWEN_GUI
object that was used in Extend because we have more than one such
object in use inside gnucash (currently). If accidentally the wrong
one would be used in Unextend, a crash occurs.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@19465 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming
2010-08-22 20:48:55 +00:00
parent 238086f863
commit fd2bbf47c4
+24 -2
View File
@@ -47,6 +47,10 @@
#include "import-utilities.h"
#include "qof.h"
#ifdef AQBANKING_VERSION_5_PLUS
# include <aqbanking/abgui.h>
#endif /* AQBANKING_VERSION_5_PLUS */
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = G_LOG_DOMAIN;
@@ -114,6 +118,8 @@ gnc_GWEN_Fini(void)
GWEN_Fini();
}
static GWEN_GUI *gnc_gwengui_extended_by_ABBanking;
AB_BANKING *
gnc_AB_BANKING_new(void)
{
@@ -180,6 +186,11 @@ gnc_AB_BANKING_new(void)
/* Init the API */
g_return_val_if_fail(AB_Banking_Init(api) == 0, NULL);
#ifdef AQBANKING_VERSION_5_PLUS
gnc_gwengui_extended_by_ABBanking = GWEN_Gui_GetGui();
AB_Gui_Extend(gnc_gwengui_extended_by_ABBanking, api);
#endif /* AQBANKING_VERSION_5_PLUS */
/* Cache it */
gnc_AB_BANKING = api;
gnc_AB_BANKING_refcount = 0;
@@ -201,8 +212,7 @@ gnc_AB_BANKING_delete(AB_BANKING *api)
if (api == gnc_AB_BANKING)
{
gnc_AB_BANKING = NULL;
if (gnc_AB_BANKING_refcount > 0)
AB_Banking_Fini(api);
gnc_AB_BANKING_fini(api);
}
AB_Banking_free(api);
@@ -216,10 +226,22 @@ gnc_AB_BANKING_fini(AB_BANKING *api)
if (api == gnc_AB_BANKING)
{
if (--gnc_AB_BANKING_refcount == 0)
{
#ifdef AQBANKING_VERSION_5_PLUS
if (gnc_gwengui_extended_by_ABBanking)
AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
gnc_gwengui_extended_by_ABBanking = NULL;
#endif /* AQBANKING_VERSION_5_PLUS */
return AB_Banking_Fini(api);
}
}
else
{
#ifdef AQBANKING_VERSION_5_PLUS
if (gnc_gwengui_extended_by_ABBanking)
AB_Gui_Unextend(gnc_gwengui_extended_by_ABBanking);
gnc_gwengui_extended_by_ABBanking = NULL;
#endif /* AQBANKING_VERSION_5_PLUS */
return AB_Banking_Fini(api);
}
return 0;