Skip to content

Commit

Permalink
fix: crash on missing RenderWidgetHostView (electron#38100)
Browse files Browse the repository at this point in the history
chore: fix crash on missing RenderWidgetHostView
  • Loading branch information
codebytere authored and felixrieseberg committed Apr 28, 2023
1 parent 8b7a54d commit 955af5a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,14 @@ - (void)redispatchContextMenuEvent:(NSEvent*)event {
// 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);
}
}
}

Expand Down

0 comments on commit 955af5a

Please sign in to comment.