From 552329423cd67e790412901a7e519c1dc58d9c1e Mon Sep 17 00:00:00 2001 From: Michal Pawluk Date: Mon, 10 Aug 2015 14:02:17 +0200 Subject: [PATCH] [SAMPLE APP][APP-COMMON] Application termination section added Change-Id: I210df0e814fe0555f46f15d71fc263906799b943 Signed-off-by: Michal Pawluk --- .../html/mobile_n/appcommon_sd_mn.htm | 46 +++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/org.tizen.sampledescriptions/html/mobile_n/appcommon_sd_mn.htm b/org.tizen.sampledescriptions/html/mobile_n/appcommon_sd_mn.htm index ed635a4..85a51f3 100644 --- a/org.tizen.sampledescriptions/html/mobile_n/appcommon_sd_mn.htm +++ b/org.tizen.sampledescriptions/html/mobile_n/appcommon_sd_mn.htm @@ -310,11 +310,55 @@ static void __init_view_app(void) If any of the above functions (except __init_view_app()) fails, then application is terminated and the - __terminate_app() callback function is called. For details, see the Application termination section. + __terminate_app() callback function is called. For details, see the Application termination section.

Application termination

+

+ When the application is terminated, then 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 events handlers. +

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

+ As the UI is not a subject for this documentation, the implementation of the view_destroy_base_gui() function is ommited. + Detaching events handlers relies on model_remove_event_handler() function for each attached event handler. For implementation + details see the Model section. +

+ +
+static void __remove_event_handlers(void)
+{
+   model_remove_event_handler(APP_EVENT_LOW_BATTERY);
+   model_remove_event_handler(APP_EVENT_LOW_MEMORY);
+   model_remove_event_handler(APP_EVENT_DEVICE_ORIENTATION_CHANGED);
+   model_remove_event_handler(APP_EVENT_LANGUAGE_CHANGED);
+   model_remove_event_handler(APP_EVENT_REGION_FORMAT_CHANGED);
+   model_remove_event_handler(APP_EVENT_SUSPENDED_STATE_CHANGED);
+}
+
+

Model

-- 2.7.4