Code refactoring about checking the EventListener of WebView class 60/104360/1
authorYoungcheol Kang <ychul.kang@samsung.com>
Tue, 13 Dec 2016 07:17:33 +0000 (16:17 +0900)
committerYoungcheol Kang <ychul.kang@samsung.com>
Tue, 13 Dec 2016 07:17:33 +0000 (16:17 +0900)
This patch refactors the codes which related to checking the
EventListener of WebView class in WebViewImpl class.

It can prevent the crash issue which happens when EventListener
was destroyed.

Bug: http://suprem.sec.samsung.net/jira/browse/TWF-2633

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

index 6ad4c2a..f964232 100644 (file)
@@ -885,26 +885,28 @@ void WebViewImpl::InitEditorClientImeCallback() {
                            Evas_Object*,
                            void* event_info) {
     WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+    if (!self->listener_)
+      return;
 
     SoftKeyboardChangeEventValue softkeyboard_value;
     softkeyboard_value.state = "on";
     softkeyboard_value.width = self->ime_width_;
     softkeyboard_value.height = self->ime_height_;
 
-    if (self->listener_)
-      self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
+    self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
   };
 
   auto ime_closed_callback = [](void* user_data,
                            Evas_Object*,
                            void* event_info) {
     WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+    if (!self->listener_)
+      return;
 
     SoftKeyboardChangeEventValue softkeyboard_value;
     softkeyboard_value.state = "off";
 
-    if (self->listener_)
-      self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
+    self->listener_->OnSoftKeyboardChangeEvent(self->view_, softkeyboard_value);
   };
   evas_object_smart_callback_add(ewk_view_,
                                  "inputmethod,changed",
@@ -929,6 +931,9 @@ void WebViewImpl::InitRotaryEventCallback() {
                          Evas_Object*,
                          Eext_Rotary_Event_Info* event_info) -> Eina_Bool {
     WebViewImpl* self = static_cast<WebViewImpl*>(user_data);
+    if (!self->listener_)
+      return;
+
     Eext_Rotary_Event_Info* rotary = event_info;
 
     RotaryEventType type;