Remove window from observers when it's closed instead of deleted.

This commit is contained in:
Cheng Zhao 2014-04-23 09:25:04 +08:00
Родитель bccbc5e821
Коммит db39910455
1 изменённых файлов: 7 добавлений и 5 удалений

Просмотреть файл

@ -75,8 +75,6 @@ Window::Window(base::DictionaryValue* options)
Window::~Window() {
Emit("destroyed");
window_->RemoveObserver(this);
}
void Window::OnPageTitleUpdated(bool* prevent_default,
@ -99,9 +97,13 @@ void Window::WillCloseWindow(bool* prevent_default) {
void Window::OnWindowClosed() {
Emit("closed");
// Free memory when native window is closed, the delete is delayed so other
// observers would not get a invalid pointer of NativeWindow.
base::MessageLoop::current()->DeleteSoon(FROM_HERE, window_.release());
if (window_) {
window_->RemoveObserver(this);
// Free memory when native window is closed, the delete is delayed so other
// observers would not get a invalid pointer of NativeWindow.
base::MessageLoop::current()->DeleteSoon(FROM_HERE, window_.release());
}
}
void Window::OnWindowBlur() {