From fc917985ae8165e0cbcc11b3bebbcc995b1bd271 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 30 Jan 2024 11:53:19 +0100 Subject: [PATCH] fix: ensure `WebContents` before checking draggable region (#41154) fix: ensure WebContents before checking draggable region --- shell/browser/api/electron_api_web_contents_view.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/shell/browser/api/electron_api_web_contents_view.cc b/shell/browser/api/electron_api_web_contents_view.cc index aabda22ff9dd..9fbc2e2b8e66 100644 --- a/shell/browser/api/electron_api_web_contents_view.cc +++ b/shell/browser/api/electron_api_web_contents_view.cc @@ -81,11 +81,14 @@ void WebContentsView::SetBackgroundColor(std::optional color) { } int WebContentsView::NonClientHitTest(const gfx::Point& point) { - gfx::Point local_point(point); - views::View::ConvertPointFromWidget(view(), &local_point); - SkRegion* region = api_web_contents_->draggable_region(); - if (region && region->contains(local_point.x(), local_point.y())) - return HTCAPTION; + if (api_web_contents_) { + gfx::Point local_point(point); + views::View::ConvertPointFromWidget(view(), &local_point); + SkRegion* region = api_web_contents_->draggable_region(); + if (region && region->contains(local_point.x(), local_point.y())) + return HTCAPTION; + } + return HTNOWHERE; }