From b59b4e7e32f194c55f2fff8af14f3b9597dfd213 Mon Sep 17 00:00:00 2001 From: Wolfgang Lux Date: Mon, 31 May 2010 21:55:33 +0000 Subject: [PATCH] Avoid a race with some lame window managers, which could lead to a crash when a window is closed and deallocated while a tool tip is visible. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@30513 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/NSWindow.m | 16 +++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c434d641f..5a624c88e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-05-31 Wolfgang Lux + + * Source/NSWindow.m (-dealloc): Avoid a race with some lame window + managers, which could lead to a crash when a window is closed and + deallocated while a tool tip is visible. + 2010-05-31 Wolfgang Lux * Source/NSDocumentController.m (-_openableFileExtensions, diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 334ce44d2..15f1b6231 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -767,6 +767,17 @@ many times. DESTROY(mini); } + /* Terminate backend window early so that the receiver is no longer returned + from GSOrderedWindows() or GSAllWindows(). This helps to prevent crashes + due to a race with some lame window managers under X that do not update + the _NET_CLIENT_LIST_STACKING property quickly enough. GSOrderedWindows() + may be called (indirectly) when a tooltip is visible while a window is + deallocated. */ + if (_windowNum) + { + [self _terminateBackendWindow]; + } + /* Clean references to this window - important if some of the views are not deallocated now */ [_wv _viewWillMoveToWindow: nil]; @@ -798,11 +809,6 @@ many times. */ [GSServerForWindow(self) removeDragTypes: nil fromWindow: self]; - if (_windowNum) - { - [self _terminateBackendWindow]; - } - if (_delegate != nil) { [nc removeObserver: _delegate name: nil object: self];