Fixed regression in SetViewCursor(). It wasn't possible anymore to switch

back to the system default cursor. For that cursor token, the global cursor
manager returns NULL.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31138 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-06-20 15:26:34 +00:00
parent 1f9fd6d866
commit 5c5195ee7e
+28 -27
View File
@@ -931,43 +931,44 @@ ServerApp::_DispatchMessage(int32 code, BPrivate::LinkReceiver& link)
if (fDesktop->GetCursorManager().Lock()) { if (fDesktop->GetCursorManager().Lock()) {
ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor( ServerCursor* cursor = fDesktop->GetCursorManager().FindCursor(
info.cursorToken); info.cursorToken);
// If we found a cursor, make sure it doesn't go away. // If we found a cursor, make sure it doesn't go away. If we
// get a NULL cursor, it probably means we are supposed to use
// the system default cursor.
if (cursor != NULL) if (cursor != NULL)
cursor->Acquire(); cursor->Acquire();
fDesktop->GetCursorManager().Unlock(); fDesktop->GetCursorManager().Unlock();
if (cursor != NULL) { // We need to acquire the write lock here, since we cannot
// We need to acquire the write lock here, since we cannot // afford that the window thread to which the view belongs
// afford that the window thread to which the view belongs // is running and messing with that same view.
// is running and messing with that same view. fDesktop->LockAllWindows();
fDesktop->LockAllWindows();
// Find the corresponding view by the given token. It's ok // Find the corresponding view by the given token. It's ok
// if this view does not exist anymore, since it may have // if this view does not exist anymore, since it may have
// already be deleted in the window thread before this // already be deleted in the window thread before this
// message got here. // message got here.
View* view; View* view;
if (fViewTokens.GetToken(info.viewToken, B_HANDLER_TOKEN, if (fViewTokens.GetToken(info.viewToken, B_HANDLER_TOKEN,
(void**)&view) == B_OK) { (void**)&view) == B_OK) {
// Set the cursor on the view. // Set the cursor on the view.
view->SetCursor(cursor); view->SetCursor(cursor);
// The cursor might need to be updated now. // The cursor might need to be updated now.
Window* window = view->Window(); Window* window = view->Window();
if (window != NULL && window->IsFocus()) { if (window != NULL && window->IsFocus()) {
if (fDesktop->ViewUnderMouse(window) if (fDesktop->ViewUnderMouse(window)
== view->Token()) { == view->Token()) {
SetCurrentCursor(cursor); SetCurrentCursor(cursor);
}
} }
} }
fDesktop->UnlockAllWindows();
// Release the temporary reference.
cursor->Release();
} }
fDesktop->UnlockAllWindows();
// Release the temporary reference.
if (cursor != NULL)
cursor->Release();
} }
if (info.sync) { if (info.sync) {