fix: try clearing InspectableWebContents delegate earlier (#49422)

fix: try clearing InspectableWebContents delegate earlier

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
This commit is contained in:
trop[bot]
2026-01-18 15:54:26 +01:00
committed by GitHub
parent 1c2b4e0583
commit 03d6462edf

View File

@@ -1045,6 +1045,9 @@ void WebContents::InitWithWebContents(
}
WebContents::~WebContents() {
if (inspectable_web_contents_)
inspectable_web_contents_->GetView()->SetDelegate(nullptr);
if (owner_window_) {
owner_window_->RemoveBackgroundThrottlingSource(this);
}
@@ -1059,8 +1062,6 @@ WebContents::~WebContents() {
return;
}
inspectable_web_contents_->GetView()->SetDelegate(nullptr);
// This event is only for internal use, which is emitted when WebContents is
// being destroyed.
Emit("will-destroy");
@@ -2196,8 +2197,8 @@ void WebContents::DevToolsOpened() {
// Inherit owner window in devtools when it doesn't have one.
auto* devtools = inspectable_web_contents_->GetDevToolsWebContents();
bool has_window = devtools->GetUserData(NativeWindowRelay::UserDataKey());
if (owner_window_ && !has_window) {
DCHECK(!owner_window_.WasInvalidated());
if (owner_window() && !has_window) {
CHECK(!owner_window_.WasInvalidated());
DCHECK_EQ(handle->owner_window(), nullptr);
handle->SetOwnerWindow(devtools, owner_window());
}