From bf3a2064455cddfc57bfc5faf36dcdb2f79d7dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Thu, 16 Oct 2008 18:01:55 +0000 Subject: [PATCH] Fixed r28168, which introduced an app_server deadlock. Functions which call into Desktop methods which in turn grab the window write lock are never supposed to hold this write lock themselves already, since the Desktop code takes care to not hold the lock when for example calling EventDispatcher methods, which would cause a deadlock (as in this example). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28175 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerWindow.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index b29b3634ce..b0f8585fc2 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -348,8 +348,7 @@ ServerWindow::ReplaceDecorator() } -/*! Shows the window's Window. You need to have all windows locked when - calling this function. +/*! Shows the window's Window. */ void ServerWindow::_Show() @@ -360,7 +359,11 @@ ServerWindow::_Show() if (fQuitting || !fWindow->IsHidden() || fWindow->IsOffscreenWindow()) return; + // TODO: Maybe we need to dispatch a message to the desktop to show/hide us + // instead of doing it from this thread. + fDesktop->UnlockSingleWindow(); fDesktop->ShowWindow(fWindow); + fDesktop->LockSingleWindow(); if (fDirectWindowData != NULL) HandleDirectConnection(B_DIRECT_START | B_BUFFER_RESET); @@ -382,7 +385,9 @@ ServerWindow::_Hide() if (fDirectWindowData != NULL) HandleDirectConnection(B_DIRECT_STOP); + fDesktop->UnlockSingleWindow(); fDesktop->HideWindow(fWindow); + fDesktop->LockSingleWindow(); } @@ -650,8 +655,10 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) _Hide(); fWindow->SetMinimized(minimize); } else if (!minimize && fWindow->IsHidden()) { + fDesktop->UnlockSingleWindow(); fDesktop->ActivateWindow(fWindow); // this will unminimize the window for us + fDesktop->LockSingleWindow(); } } @@ -749,7 +756,8 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link) status = B_BAD_VALUE; } else { //fDesktop->UnlockSingleWindow(); -// TODO: there is a big race condition when we unlock here (window could be gone by now)! +// TODO: there is a big race condition when we unlock here +// (window could be gone by now)! status = fDesktop->AddWindowToSubset(fWindow, window) ? B_OK : B_NO_MEMORY; //fDesktop->LockSingleWindow(); @@ -3429,10 +3437,7 @@ bool ServerWindow::_MessageNeedsAllWindowsLocked(uint32 code) const { switch (code) { - case AS_SHOW_WINDOW: - case AS_HIDE_WINDOW: case AS_ACTIVATE_WINDOW: - case AS_MINIMIZE_WINDOW: case AS_SET_WINDOW_TITLE: case AS_ADD_TO_SUBSET: case AS_REMOVE_FROM_SUBSET: