From f4b7e59b2d4ec7e6c15574d476feae5a862ee498 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 25 Apr 2023 11:30:16 +0200 Subject: [PATCH] fix: crash on missing `RenderWidgetHostView` (#38100) chore: fix crash on missing RenderWidgetHostView --- .../electron_inspectable_web_contents_view.mm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm b/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm index 1790ed888737..3c8a73fe012e 100644 --- a/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm +++ b/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm @@ -287,12 +287,14 @@ // Temporarily pretend that the WebContents is fully non-draggable while we // re-send the mouse event. This allows the re-dispatched event to "land" // on the WebContents, instead of "falling through" back to the window. - api_contents->SetForceNonDraggable(true); - BaseView* contentsView = (BaseView*)contents->GetRenderWidgetHostView() - ->GetNativeView() - .GetNativeNSView(); - [contentsView mouseEvent:event]; - api_contents->SetForceNonDraggable(false); + auto* rwhv = contents->GetRenderWidgetHostView(); + if (rwhv) { + api_contents->SetForceNonDraggable(true); + BaseView* contentsView = + (BaseView*)rwhv->GetNativeView().GetNativeNSView(); + [contentsView mouseEvent:event]; + api_contents->SetForceNonDraggable(false); + } } }