Commit 133ead2f authored by jam's avatar jam Committed by Commit bot

Don't destroy the window in PlatformWindow's destructor.

This should have already been closed before we get to the destructor. Otherwise we get double deletes since the Destroy() call can end up calling the delegate which will delete this object.

Also in the X11 implementation, don't call delegate's OnClosed() before null'ing xwindow_, otherwise Destroy() can be called multiple times.

This is split off https://codereview.chromium.org/1139673003

BUG=484234

Review URL: https://codereview.chromium.org/1132313003

Cr-Commit-Position: refs/heads/master@{#330381}
parent cd24f7e8
...@@ -49,7 +49,6 @@ WinWindow::WinWindow(PlatformWindowDelegate* delegate, ...@@ -49,7 +49,6 @@ WinWindow::WinWindow(PlatformWindowDelegate* delegate,
} }
WinWindow::~WinWindow() { WinWindow::~WinWindow() {
Destroy();
} }
void WinWindow::Destroy() { void WinWindow::Destroy() {
......
...@@ -52,18 +52,21 @@ X11Window::X11Window(PlatformWindowDelegate* delegate) ...@@ -52,18 +52,21 @@ X11Window::X11Window(PlatformWindowDelegate* delegate)
} }
X11Window::~X11Window() { X11Window::~X11Window() {
Destroy();
} }
void X11Window::Destroy() { void X11Window::Destroy() {
delegate_->OnClosed();
if (xwindow_ == None) if (xwindow_ == None)
return; return;
// Stop processing events. // Stop processing events.
PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this); PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
XDestroyWindow(xdisplay_, xwindow_); XID xwindow = xwindow_;
XDisplay* xdisplay = xdisplay_;
xwindow_ = None; xwindow_ = None;
delegate_->OnClosed();
// |this| might be deleted because of the above call.
XDestroyWindow(xdisplay, xwindow);
} }
void X11Window::ProcessXInput2Event(XEvent* xev) { void X11Window::ProcessXInput2Event(XEvent* xev) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment