From: Michal Pawluk Date: Fri, 21 Aug 2015 12:36:59 +0000 (+0200) Subject: [SAMPLE APP][EVENT] Application's termination section added X-Git-Tag: tizen_3.0/TD_SYNC/20161201~539^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=01a5818b7f49a6ef6ae3e26aab50e5a75f2f1b45;p=sdk%2Fonline-doc.git [SAMPLE APP][EVENT] Application's termination section added Change-Id: I592fceb477d39c8ab022a385175146b9a0f31a40 Signed-off-by: Michal Pawluk --- 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