Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Unified Diff: ui/platform_window/x11/x11_window.cc

Issue 1139673003: Make Mandoline shut down cleanly. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix crash in surfaces if surfaceimpl outlives the app, and a double delete in browser Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/platform_window/x11/x11_window.cc
diff --git a/ui/platform_window/x11/x11_window.cc b/ui/platform_window/x11/x11_window.cc
index 14e6fdf0b282421af5e88e7bf8c6c27032543337..5e8f41118b95f3b1b083c0f31d5b1948957f8ff5 100644
--- a/ui/platform_window/x11/x11_window.cc
+++ b/ui/platform_window/x11/x11_window.cc
@@ -46,7 +46,8 @@ X11Window::X11Window(PlatformWindowDelegate* delegate)
xwindow_(None),
xroot_window_(DefaultRootWindow(xdisplay_)),
atom_cache_(xdisplay_, kAtomsToCache),
- window_mapped_(false) {
+ window_mapped_(false),
+ destroyed_(false) {
CHECK(delegate_);
TouchFactory::SetTouchDeviceListFromCommandLine();
}
@@ -56,14 +57,20 @@ X11Window::~X11Window() {
}
void X11Window::Destroy() {
- delegate_->OnClosed();
- if (xwindow_ == None)
+ if (destroyed_)
return;
- // Stop processing events.
- PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
- XDestroyWindow(xdisplay_, xwindow_);
- xwindow_ = None;
+ destroyed_ = true;
+
+ if (xwindow_ != None) {
+ // Stop processing events.
+ PlatformEventSource::GetInstance()->RemovePlatformEventDispatcher(this);
+ XDestroyWindow(xdisplay_, xwindow_);
+ xwindow_ = None;
+ }
+
+ delegate_->OnClosed();
+ // |this| could be deleted now.
}
void X11Window::ProcessXInput2Event(XEvent* xev) {
« ui/platform_window/win/win_window.cc ('K') | « ui/platform_window/x11/x11_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698