Skip to content

Commit

Permalink
app-utils - make gnc-expression-parser responsible for its own cleanup
Browse files Browse the repository at this point in the history
It already ensured it would initialize on first use.
It can as well register the hooks it needs for its
cleanup directly itself instead of depending on the
module loading system to do so.
  • Loading branch information
gjanssens committed Dec 6, 2019
1 parent 43647c7 commit 90aa539
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
5 changes: 5 additions & 0 deletions libgnucash/app-utils/gnc-exp-parser.c
Expand Up @@ -32,6 +32,7 @@
#include "fin_spl_protos.h"
#include "gnc-filepath-utils.h"
#include "gnc-gkeyfile-utils.h"
#include "gnc-hooks.h"
#include "gnc-exp-parser.h"
#include "gnc-ui-util.h"
#include "gnc-locale-utils.h"
Expand Down Expand Up @@ -107,6 +108,8 @@ gnc_exp_parser_real_init ( gboolean addPredefined )
}
g_free(filename);
}

gnc_hook_add_dangler(HOOK_SHUTDOWN, (GFunc)gnc_exp_parser_shutdown, NULL, NULL);
}

static gboolean
Expand Down Expand Up @@ -157,6 +160,8 @@ gnc_exp_parser_shutdown (void)
last_gncp_error = NO_ERR;

parser_inited = FALSE;

gnc_hook_run(HOOK_SAVE_OPTIONS, NULL);
}

void
Expand Down
13 changes: 0 additions & 13 deletions libgnucash/app-utils/gncmod-app-utils.c
Expand Up @@ -66,13 +66,6 @@ lmod(char * mn)
g_free(form);
}

static void
app_utils_shutdown(void)
{
gnc_exp_parser_shutdown();
gnc_hook_run(HOOK_SAVE_OPTIONS, NULL);
}


extern SCM scm_init_sw_app_utils_module(void);

Expand All @@ -85,12 +78,6 @@ libgncmod_app_utils_gnc_module_init(int refcount)
lmod("(sw_app_utils)");
lmod("(gnucash app-utils)");

if (refcount == 0)
{
gnc_hook_add_dangler(HOOK_STARTUP, (GFunc)gnc_exp_parser_init, NULL, NULL);
gnc_hook_add_dangler(HOOK_SHUTDOWN, (GFunc)app_utils_shutdown, NULL, NULL);
}

return TRUE;
}

Expand Down

0 comments on commit 90aa539

Please sign in to comment.