From 01a5818b7f49a6ef6ae3e26aab50e5a75f2f1b45 Mon Sep 17 00:00:00 2001 From: Michal Pawluk Date: Fri, 21 Aug 2015 14:36:59 +0200 Subject: [PATCH] [SAMPLE APP][EVENT] Application's termination section added Change-Id: I592fceb477d39c8ab022a385175146b9a0f31a40 Signed-off-by: Michal Pawluk --- .../html/mobile_n/event_sd_mn.htm | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/org.tizen.sampledescriptions/html/mobile_n/event_sd_mn.htm b/org.tizen.sampledescriptions/html/mobile_n/event_sd_mn.htm index f635442..794e36e 100644 --- a/org.tizen.sampledescriptions/html/mobile_n/event_sd_mn.htm +++ b/org.tizen.sampledescriptions/html/mobile_n/event_sd_mn.htm @@ -361,6 +361,87 @@ bool __controller_register_custom_event(const char *event_name, custom_ev_info_s

Application termination

+

+ When the application is terminated, the __terminate_app() callback function is called (see the code snippet below). +

+ +
+static void __terminate_app(void *data)
+{
+   appdata_s *ad = (appdata_s *)data;
+
+   controller_finit(&ad->view);
+}
+
+ +

+ All the resources, allocated previously, are released with controller_finit() function, which is responsible for destroying the UI + and detaching system and custom events handlers. +

+ +
+void controller_finit(viewdata_s *vd)
+{
+   view_destroy_base_gui(vd);
+   model_finit();
+}
+
+ +

+ As the UI is not a subject for this documentation, the implementation of the view_destroy_base_gui() function is ommited. + Detaching events handlers is performed in the Model module within the model_finit() function, which calls two internal functions: + __model_release_system_events() and __model_release_custom_events(). +

+ +
+void model_finit(void)
+{
+   __model_release_system_events();
+   __model_release_custom_events();
+}
+
+ +

+ The events handlers detaching procedure relies on __model_remove_event_handler() function (for reference see the + Model section) for each attached event handler regardless of its type (system or custom). The related resources are freed with the + __model_free_system_event_info() and + __model_free_custom_event_info() functions. +

+ +
+static void __model_release_system_events(void)
+{
+   int i;
+   for (i = 0; i < __SYSTEM_EVENT_COUNT_MAX; i++) {
+      system_ev_info_s *ev_info = &__system_ev[i];
+
+      __model_remove_event_handler(ev_info->event_h);
+      __model_free_system_event_info(ev_info);
+   }
+}
+
+ +
+static void __model_release_custom_events(void)
+{
+   int i;
+   for (i = 0; i < __custom_ev_count; i++) {
+      custom_ev_info_s *ev_info = &__custom_ev[i];
+
+      __model_remove_event_handler(ev_info->event_h);
+      __model_free_custom_event_info(ev_info);
+   }
+
+   __custom_ev_count = 0;
+}
+
+ +

+ The __model_free_system_event_info() and + __model_free_custom_event_info() functions are not listed here, as their implementation is based only on + free() function used to free the previously allocated memory. +

+

System events

Custom events

-- 2.7.4