[Application] Add removing event_handler in destructor. 52/176152/2
authorLukasz Bardeli <l.bardeli@samsung.com>
Tue, 17 Apr 2018 08:46:44 +0000 (10:46 +0200)
committerLukasz Bardeli <l.bardeli@samsung.com>
Tue, 17 Apr 2018 08:46:44 +0000 (10:46 +0200)
Removing all event_handler from events while closing application.
Without removing event_handler it is possible that native api will call
event with destroyed data. This fix is to prevent such situation

[Verification] Code compiles without error. TCT passrate 100%

Change-Id: I94d1fbb85ad47ca6dbcba6c56cd043521952860e
Signed-off-by: Lukasz Bardeli <l.bardeli@samsung.com>
src/application/application_manager.cc

index 365482b..23025be 100644 (file)
@@ -117,6 +117,14 @@ ApplicationManager::~ApplicationManager() {
   StopAppInfoEventListener();
   StopStatusChangeListener();
 
+  for (auto it = event_handler_map_.begin(); it != event_handler_map_.end();) {
+    int ret = event_remove_event_handler(it->second);
+    if (EVENT_ERROR_NONE != ret) {
+      LoggerE("event_remove_event_handler failed, error: %d (%s)", ret, get_error_message(ret));
+    }
+    it = event_handler_map_.erase(it);
+  }
+
   if (app_status_handle_) {
     int ret = app_manager_event_destroy(app_status_handle_);
     if (APP_MANAGER_ERROR_NONE != ret) {