fix: potentially closed webContents in BrowserView (#42633)
This commit is contained in:
parent
2f4a46f47a
commit
cb2e7f130b
4 changed files with 107 additions and 21 deletions
|
@ -249,14 +249,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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue