fix: potentially closed webContents in BrowserView (#42810)

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 15:33:27 +02:00
committed by GitHub
parent 6a15e168ce
commit dc065dfa5a
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);
}
}