Check BrowserWindow's lifetime

This commit is contained in:
Cheng Zhao 2015-07-06 18:28:42 +08:00
parent 1569dfa2e8
commit ae52af3870
2 changed files with 7 additions and 0 deletions

View file

@ -177,6 +177,10 @@ mate::Wrappable* Window::New(v8::Isolate* isolate,
return new Window(isolate, options); return new Window(isolate, options);
} }
bool Window::IsDestroyed() const {
return !window_ || window_->IsClosed();
}
void Window::Destroy() { void Window::Destroy() {
window_->CloseContents(nullptr); window_->CloseContents(nullptr);
} }

View file

@ -73,6 +73,9 @@ class Window : public mate::TrackableObject<Window>,
void OnDevToolsClosed() override; void OnDevToolsClosed() override;
void OnExecuteWindowsCommand(const std::string& command_name) override; void OnExecuteWindowsCommand(const std::string& command_name) override;
// mate::Wrappable:
bool IsDestroyed() const override;
private: private:
// APIs for NativeWindow. // APIs for NativeWindow.
void Destroy(); void Destroy();