Fixed the crash when the app is terminated through h/w back-key 23/104323/1
authorYoungcheol Kang <ychul.kang@samsung.com>
Tue, 13 Dec 2016 05:54:50 +0000 (14:54 +0900)
committerYoungcheol Kang <ychul.kang@samsung.com>
Tue, 13 Dec 2016 05:54:50 +0000 (14:54 +0900)
The crash happens due to the callback which occur after destroying
WebApplication class. this patch adds the codes to prevent this
crash issue by checking the EventListener of WebView class.

Bug: http://suprem.sec.samsung.net/jira/browse/TSAM-11504

Change-Id: Ie27666ee604bf375bfc34a43e5e8f24eda758a22
Signed-off-by: Youngcheol Kang <ychul.kang@samsung.com>
runtime/browser/web_application.cc
runtime/browser/web_view_impl.cc

index 6a58733febbd0cdd34fea782d7144e076c08f54f..59b8611a4d40f237f05249707f0b17888fd52003 100755 (executable)
@@ -567,10 +567,18 @@ void WebApplication::RemoveWebViewFromStack(WebView* view) {
 
   WebView* current = view_stack_.front();
   if (current == view) {
+    // In order to prevent the crash issue due to the callback
+    // which occur after destroying WebApplication class,
+    // we have to set the 'SetEventListener' to NULL.
+    view->SetEventListener(NULL);
     view_stack_.pop_front();
   } else {
     auto found = std::find(view_stack_.begin(), view_stack_.end(), view);
     if (found != view_stack_.end()) {
+      // In order to prevent the crash issue due to the callback
+      // which occur after destroying WebApplication class,
+      // we have to set the 'SetEventListener' to NULL.
+      view->SetEventListener(NULL);
       view_stack_.erase(found);
     }
   }
index e1fdc300a514417730e06f5ac9fa9bd5dea10caa..7bab294a415415666fd14f0dd498d532375c5c16 100644 (file)
@@ -890,7 +890,8 @@ void WebViewImpl::InitEditorClientImeCallback() {
     softkeyboard_value.width = self->ime_width_;
     softkeyboard_value.height = self->ime_height_;
 
-    self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
+    if (self->listener_)
+      self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
   };
 
   auto ime_closed_callback = [](void* user_data,
@@ -901,7 +902,8 @@ void WebViewImpl::InitEditorClientImeCallback() {
     SoftKeyboardChangeEventValue softkeyboard_value;
     softkeyboard_value.state = "off";
 
-    self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
+    if (self->listener_)
+      self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
   };
   evas_object_smart_callback_add(ewk_view_,
                                  "inputmethod,changed",