[M120 Migration] Possible fix for crash during shutdown insideSelectionControllerEfl... 12/308812/4
authorManjeet <manjeet.1@partner.samsung.com>
Mon, 1 Apr 2024 10:26:36 +0000 (15:56 +0530)
committerBot Blink <blinkbot@samsung.com>
Wed, 3 Apr 2024 18:03:25 +0000 (18:03 +0000)
In pre-aura, WebContentViewEfl was owned by RWHVEfl, so the order of destruction
was guaranteed. But in post-aura, WCVAHelper is owned by WCVA, so during shutdown,
sometimes due to destruction sync issue, WCVAHelper may not be a valid pointer
in SelectionControllerEfl (which is a member of RWHVHelper). So instead of using
WCVAHelper, use WebContentsEflDelegate directly to show and cancel context menu in
SelectionControllerEfl class.

Reference:
https://review.tizen.org/gerrit/295842

Change-Id: Ic01aa40000567e8605af47a46163462e3196e57e

tizen_src/chromium_impl/content/browser/selection/selection_controller_efl.cc

index bde133e..c148e38 100644 (file)
@@ -15,6 +15,7 @@
 #include "content/browser/web_contents/web_contents_view_aura.h"
 #include "content/public/browser/context_menu_params.h"
 #include "content/public/browser/web_contents.h"
+#include "ewk/efl_integration/webview_delegate_efl.h"
 #include "tizen/system_info.h"
 #include "ui/base/clipboard/clipboard_helper_efl.h"
 #include "ui/display/device_display_info_efl.h"
@@ -467,20 +468,23 @@ void SelectionControllerEfl::ShowContextMenu() {
   // TODO(a1.gomes): In case of EWK apps, the call below end up calling
   // EWebView::ShowContextMenu. We have to make sure parameters
   // are correct.
-  WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents());
-  WebContentsViewAura* wcva = static_cast<WebContentsViewAura*>(wci->GetView());
-  wcva->wcva_helper()->ShowContextMenu(convertedParams);
-}
+  WebContentsImplEfl* wcie = static_cast<WebContentsImplEfl*>(web_contents());
+  if (!wcie || !wcie->GetEflDelegate())
+    return;
 
+  wcie->GetEflDelegate()->ShowContextMenu(convertedParams);
+}
 void SelectionControllerEfl::CancelContextMenu(int request_id) {
   if (IsMobileProfile() && (context_menu_status_ == ContextMenuStatus::HIDDEN ||
                             context_menu_status_ == ContextMenuStatus::NONE)) {
     return;
   }
 
-  WebContentsImpl* wci = static_cast<WebContentsImpl*>(web_contents());
-  WebContentsViewAura* wcva = static_cast<WebContentsViewAura*>(wci->GetView());
-  wcva->wcva_helper()->CancelContextMenu(request_id);
+  WebContentsImplEfl* wcie = static_cast<WebContentsImplEfl*>(web_contents());
+  if (!wcie || !wcie->GetEflDelegate())
+    return;
+
+  wcie->GetEflDelegate()->CancelContextMenu(request_id);
 }
 
 void SelectionControllerEfl::HideHandles() {