From 48e7dbd1d24d577257e7de7332ed1c46a824a9c0 Mon Sep 17 00:00:00 2001 From: Youngcheol Kang Date: Tue, 13 Dec 2016 14:54:50 +0900 Subject: [PATCH] Fixed the crash when the app is terminated through h/w back-key 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 --- runtime/browser/web_application.cc | 8 ++++++++ runtime/browser/web_view_impl.cc | 6 ++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/runtime/browser/web_application.cc b/runtime/browser/web_application.cc index 6a58733..59b8611 100755 --- a/runtime/browser/web_application.cc +++ b/runtime/browser/web_application.cc @@ -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); } } diff --git a/runtime/browser/web_view_impl.cc b/runtime/browser/web_view_impl.cc index e1fdc30..7bab294 100644 --- a/runtime/browser/web_view_impl.cc +++ b/runtime/browser/web_view_impl.cc @@ -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", -- 2.7.4