* 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
This commit is contained in:
Axel Dörfler
2009-08-21 18:08:04 +00:00
parent 67838392dc
commit 91d5822a7c
+18 -13
View File
@@ -452,19 +452,22 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
case AS_APP_CRASHED: case AS_APP_CRASHED:
// Allow the debugger to show its window: if needed, remove any // Allow the debugger to show its window: if needed, remove any
// kWindowScreenFeels from the windows of this application // kWindowScreenFeels from the windows of this application
if (fWindowListLock.Lock()) { if (fDesktop->LockAllWindows()) {
for (int32 i = fWindowList.CountItems(); i-- > 0;) { if (fWindowListLock.Lock()) {
ServerWindow* serverWindow = fWindowList.ItemAt(i); for (int32 i = fWindowList.CountItems(); i-- > 0;) {
ServerWindow* serverWindow = fWindowList.ItemAt(i);
Window* window = serverWindow->Window(); Window* window = serverWindow->Window();
if (window == NULL || window->IsOffscreenWindow()) if (window == NULL || window->IsOffscreenWindow())
continue; continue;
if (window->Feel() == kWindowScreenFeel) if (window->Feel() == kWindowScreenFeel)
fDesktop->SetWindowFeel(window, B_NORMAL_WINDOW_FEEL); fDesktop->SetWindowFeel(window, B_NORMAL_WINDOW_FEEL);
}
fWindowListLock.Unlock();
} }
fDesktop->UnlockAllWindows();
fWindowListLock.Unlock();
} }
break; break;
@@ -2256,7 +2259,7 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
int32 clientToken; int32 clientToken;
if (link.Read<int32>(&clientToken) != B_OK) if (link.Read<int32>(&clientToken) != B_OK)
status = B_BAD_DATA; status = B_BAD_DATA;
else { else if (fDesktop->LockAllWindows()) {
BAutolock locker(fWindowListLock); BAutolock locker(fWindowListLock);
for (int32 i = fWindowList.CountItems(); i-- > 0;) { for (int32 i = fWindowList.CountItems(); i-- > 0;) {
@@ -2270,7 +2273,9 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
break; break;
} }
} }
} fDesktop->UnlockAllWindows();
} else
status = B_ERROR;
if (status != B_OK) if (status != B_OK)
fLink.StartMessage(status); fLink.StartMessage(status);
@@ -2894,7 +2899,7 @@ ServerApp::_CreateWindow(int32 code, BPrivate::LinkReceiver& link,
status = B_ERROR; status = B_ERROR;
} }
if (status < B_OK) if (status != B_OK)
delete window; delete window;
} }