fix: crash in BrowserWindow destructor after win.webContents.destroy() (#18686)
This commit is contained in:
parent
da58ac7c20
commit
6e327184bd
4 changed files with 17 additions and 7 deletions
|
@ -66,7 +66,7 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
|||
}
|
||||
|
||||
web_contents_.Reset(isolate, web_contents.ToV8());
|
||||
api_web_contents_ = web_contents.get();
|
||||
api_web_contents_ = web_contents->GetWeakPtr();
|
||||
api_web_contents_->AddObserver(this);
|
||||
Observe(api_web_contents_->web_contents());
|
||||
|
||||
|
@ -93,7 +93,9 @@ BrowserWindow::BrowserWindow(v8::Isolate* isolate,
|
|||
}
|
||||
|
||||
BrowserWindow::~BrowserWindow() {
|
||||
api_web_contents_->RemoveObserver(this);
|
||||
// FIXME This is a hack rather than a proper fix preventing shutdown crashes.
|
||||
if (api_web_contents_)
|
||||
api_web_contents_->RemoveObserver(this);
|
||||
// Note that the OnWindowClosed will not be called after the destructor runs,
|
||||
// since the window object is managed by the TopLevelWindow class.
|
||||
if (web_contents())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue