From 60a981fbbea0c565df005fc6f82379f8e072c845 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Fri, 4 Sep 2009 03:51:15 +0000 Subject: [PATCH] When a focus locked window is hidden, we need to remove the focus lock. Otherwise the focus cannot be changed to another window. In one case this could have a severe sideeffect: When a window is quit it is hidden to remove focus and remove it from screen. If this didn't work due to the focus lock, the fFocus member would become a stale pointer after the window was quit and deleted. The app_server would crash or corrupt memory on the next focus change. Easily seen when moderately quickly clicking away a few alert windows. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32929 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/Desktop.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp index 1540bc3583..f533c93781 100644 --- a/src/servers/app/Desktop.cpp +++ b/src/servers/app/Desktop.cpp @@ -1065,16 +1065,21 @@ Desktop::HideWindow(Window* window) fMouseEventWindow = NULL; } + if (fLockedFocusWindow == window) { + // Remove the focus lock so the focus can be changed below + fLockedFocusWindow = NULL; + } + if (window->InWorkspace(fCurrentWorkspace)) { _UpdateSubsetWorkspaces(window); _HideWindow(window); _UpdateFronts(); - - if (FocusWindow() == window) - SetFocusWindow(); } else _WindowChanged(window); + if (FocusWindow() == window) + SetFocusWindow(); + _WindowRemoved(window); if (window->HasWorkspacesViews()) {