From 90aa53990853b54b04c43387634f81f1d8931125 Mon Sep 17 00:00:00 2001 From: Geert Janssens Date: Tue, 26 Nov 2019 17:03:12 +0100 Subject: [PATCH] app-utils - make gnc-expression-parser responsible for its own cleanup 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. --- libgnucash/app-utils/gnc-exp-parser.c | 5 +++++ libgnucash/app-utils/gncmod-app-utils.c | 13 ------------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/libgnucash/app-utils/gnc-exp-parser.c b/libgnucash/app-utils/gnc-exp-parser.c index 35179f33a1..fdfab3aa11 100644 --- a/libgnucash/app-utils/gnc-exp-parser.c +++ b/libgnucash/app-utils/gnc-exp-parser.c @@ -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" @@ -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 @@ -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 diff --git a/libgnucash/app-utils/gncmod-app-utils.c b/libgnucash/app-utils/gncmod-app-utils.c index 3f242d243f..24ab94d93c 100644 --- a/libgnucash/app-utils/gncmod-app-utils.c +++ b/libgnucash/app-utils/gncmod-app-utils.c @@ -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); @@ -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; }