[Haiku-commits] r28175 - haiku/trunk/src/servers/app

stippi at mail.berlios.de stippi at mail.berlios.de
Thu Oct 16 20:01:56 CEST 2008


Author: stippi
Date: 2008-10-16 20:01:55 +0200 (Thu, 16 Oct 2008)
New Revision: 28175
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=28175&view=rev

Modified:
   haiku/trunk/src/servers/app/ServerWindow.cpp
Log:
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).


Modified: haiku/trunk/src/servers/app/ServerWindow.cpp
===================================================================
--- haiku/trunk/src/servers/app/ServerWindow.cpp	2008-10-16 15:55:36 UTC (rev 28174)
+++ haiku/trunk/src/servers/app/ServerWindow.cpp	2008-10-16 18:01:55 UTC (rev 28175)
@@ -348,8 +348,7 @@
 }
 
 
-/*! 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 @@
 	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 @@
 	if (fDirectWindowData != NULL)
 		HandleDirectConnection(B_DIRECT_STOP);
 
+	fDesktop->UnlockSingleWindow();
 	fDesktop->HideWindow(fWindow);
+	fDesktop->LockSingleWindow();
 }
 
 
@@ -650,8 +655,10 @@
 					_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 @@
 					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 @@
 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:




More information about the Haiku-commits mailing list