fix: potentially closed webContents in BrowserView (#42811)

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] 2024-07-10 11:18:17 -04:00 committed by GitHub
parent 06308d8f23
commit 474c4b43db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 107 additions and 21 deletions

View file

@ -248,14 +248,16 @@ void View::AddChildViewAt(gin::Handle<View> child,
void View::RemoveChildView(gin::Handle<View> child) {
if (!view_)
return;
if (!child->view())
return;
const auto it = base::ranges::find(child_views_, child.ToV8());
if (it != child_views_.end()) {
#if BUILDFLAG(IS_MAC)
ScopedCAActionDisabler disable_animations;
#endif
view_->RemoveChildView(child->view());
// It's possible for the child's view to be invalid here
// if the child's webContents was closed or destroyed.
if (child->view())
view_->RemoveChildView(child->view());
child_views_.erase(it);
}
}