From 91d5822a7c0a340c216fa9703cc568935366aa18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 21 Aug 2009 18:08:04 +0000 Subject: [PATCH] * The code to handle AS_GET_SCREEN_ID_FROM_WINDOW did not lock the desktop, which got unnoticed since the former Desktop::ActiveScreen() never changed. This fixes bug #4301. * Also fixed a possible deadlock on application crash with a kWindowScreenFeel window; the locking order of the Desktop's and the ServerApp's window lock was reversed. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32578 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerApp.cpp | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp index d716b873c0..c9efd15de7 100644 --- a/src/servers/app/ServerApp.cpp +++ b/src/servers/app/ServerApp.cpp @@ -452,19 +452,22 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) case AS_APP_CRASHED: // Allow the debugger to show its window: if needed, remove any // kWindowScreenFeels from the windows of this application - if (fWindowListLock.Lock()) { - for (int32 i = fWindowList.CountItems(); i-- > 0;) { - ServerWindow* serverWindow = fWindowList.ItemAt(i); + if (fDesktop->LockAllWindows()) { + if (fWindowListLock.Lock()) { + for (int32 i = fWindowList.CountItems(); i-- > 0;) { + ServerWindow* serverWindow = fWindowList.ItemAt(i); - Window* window = serverWindow->Window(); - if (window == NULL || window->IsOffscreenWindow()) - continue; + Window* window = serverWindow->Window(); + if (window == NULL || window->IsOffscreenWindow()) + continue; - if (window->Feel() == kWindowScreenFeel) - fDesktop->SetWindowFeel(window, B_NORMAL_WINDOW_FEEL); + if (window->Feel() == kWindowScreenFeel) + fDesktop->SetWindowFeel(window, B_NORMAL_WINDOW_FEEL); + } + + fWindowListLock.Unlock(); } - - fWindowListLock.Unlock(); + fDesktop->UnlockAllWindows(); } break; @@ -2256,7 +2259,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) int32 clientToken; if (link.Read(&clientToken) != B_OK) status = B_BAD_DATA; - else { + else if (fDesktop->LockAllWindows()) { BAutolock locker(fWindowListLock); for (int32 i = fWindowList.CountItems(); i-- > 0;) { @@ -2270,7 +2273,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link) break; } } - } + fDesktop->UnlockAllWindows(); + } else + status = B_ERROR; if (status != B_OK) fLink.StartMessage(status); @@ -2894,7 +2899,7 @@ ServerApp::_CreateWindow(int32 code, BPrivate::LinkReceiver& link, status = B_ERROR; } - if (status < B_OK) + if (status != B_OK) delete window; }