From ac1529bc879f49dbd330fdeac4f84229cfeea989 Mon Sep 17 00:00:00 2001 From: Junghoon Park Date: Thu, 23 Feb 2017 22:09:38 +0900 Subject: [PATCH] Fix bug about setting event handler Change-Id: I5fd868f5bf41ec3b1e1e380686d4bad7e122092b Signed-off-by: Junghoon Park --- src/base/appcore_base.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/base/appcore_base.c b/src/base/appcore_base.c index 93e2f56..7a15b33 100644 --- a/src/base/appcore_base.c +++ b/src/base/appcore_base.c @@ -51,6 +51,7 @@ typedef struct _appcore_base_context { unsigned int tid; bool suspended_state; bool allowed_bg; + bool dirty; } appcore_base_context; typedef struct _appcore_base_event_node { @@ -683,6 +684,8 @@ EXPORT_API int appcore_base_on_set_i18n(void) EXPORT_API int appcore_base_init(appcore_base_ops ops, int argc, char **argv, void *data) { + int i; + __context.ops = ops; __context.argc = argc; __context.argv = argv; @@ -696,6 +699,17 @@ EXPORT_API int appcore_base_init(appcore_base_ops ops, int argc, char **argv, vo __init_suspend_dbus_handler(); + if (!__context.dirty) { + __context.dirty = true; + + for (i = APPCORE_BASE_EVENT_START + 1; i < APPCORE_BASE_EVENT_MAX; i++) { + if (__exist_callback(i)) { + if (__context.ops.set_event) + __context.ops.set_event(i, __context.data); + } + } + } + if (__context.ops.create && __context.ops.create(__context.data) < 0) { aul_status_update(STATUS_DYING); return 0; @@ -711,6 +725,10 @@ EXPORT_API void appcore_base_fini(void) { int i; + aul_status_update(STATUS_DYING); + if (__context.ops.terminate) + __context.ops.terminate(__context.data); + for (i = APPCORE_BASE_EVENT_START + 1; i < APPCORE_BASE_EVENT_MAX; i++) { if (__exist_callback(i)) { if (__context.ops.unset_event) @@ -722,14 +740,12 @@ EXPORT_API void appcore_base_fini(void) __events = NULL; __fini_suspend_dbus_handler(); - aul_status_update(STATUS_DYING); - if (__context.ops.terminate) - __context.ops.terminate(__context.data); - if (__locale_dir) { free(__locale_dir); __locale_dir = NULL; } + + __context.dirty = false; } EXPORT_API int appcore_base_flush_memory(void) @@ -917,7 +933,7 @@ EXPORT_API appcore_base_event_h appcore_base_add_event(enum appcore_base_event e { appcore_base_event_node *node; - if (!__exist_callback(event)) { + if (__context.dirty && !__exist_callback(event)) { if (__context.ops.set_event) __context.ops.set_event(event, __context.data); } @@ -943,7 +959,7 @@ EXPORT_API int appcore_base_remove_event(appcore_base_event_h handle) event = node->type; __events = g_list_remove(__events, node); free(node); - if (!__exist_callback(event)) { + if (__context.dirty && !__exist_callback(event)) { if (__context.ops.unset_event) __context.ops.unset_event(event, __context.data); } -- 2.7.4