Destroy the native window in next tick
It fixes a possible crash when native code is iterating all windows while the JavaScript code decides to destroy a window.
This commit is contained in:
parent
2c6d232254
commit
973ae06f21
1 changed files with 4 additions and 0 deletions
|
@ -159,6 +159,10 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) {
|
||||||
Window::~Window() {
|
Window::~Window() {
|
||||||
if (!window_->IsClosed())
|
if (!window_->IsClosed())
|
||||||
window_->CloseContents(nullptr);
|
window_->CloseContents(nullptr);
|
||||||
|
|
||||||
|
// Destroy the native window in next tick because the native code might be
|
||||||
|
// iterating all windows.
|
||||||
|
base::MessageLoop::current()->DeleteSoon(FROM_HERE, window_.release());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::WillCloseWindow(bool* prevent_default) {
|
void Window::WillCloseWindow(bool* prevent_default) {
|
||||||
|
|
Loading…
Reference in a new issue