app_server: Properly lock the HWInterface in cursor routines.
A comment in the header says the cursor handling functions "do their own Read/Write locking", but they didn't actually lock the framebuffer. Should fix #20141 and #2539.
This commit is contained in:
@@ -120,7 +120,7 @@ HWInterface::SetCursor(ServerCursor* cursor)
|
|||||||
if (!fFloatingOverlaysLock.Lock())
|
if (!fFloatingOverlaysLock.Lock())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fCursor.Get() != cursor) {
|
if (fCursor.Get() != cursor && LockParallelAccess()) {
|
||||||
BRect oldFrame = _CursorFrame();
|
BRect oldFrame = _CursorFrame();
|
||||||
|
|
||||||
fCursor.SetTo(cursor);
|
fCursor.SetTo(cursor);
|
||||||
@@ -129,6 +129,8 @@ HWInterface::SetCursor(ServerCursor* cursor)
|
|||||||
|
|
||||||
_AdoptDragBitmap();
|
_AdoptDragBitmap();
|
||||||
Invalidate(_CursorFrame());
|
Invalidate(_CursorFrame());
|
||||||
|
|
||||||
|
UnlockParallelAccess();
|
||||||
}
|
}
|
||||||
fFloatingOverlaysLock.Unlock();
|
fFloatingOverlaysLock.Unlock();
|
||||||
}
|
}
|
||||||
@@ -162,7 +164,7 @@ HWInterface::SetCursorVisible(bool visible)
|
|||||||
if (!fFloatingOverlaysLock.Lock())
|
if (!fFloatingOverlaysLock.Lock())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (fCursorVisible != visible) {
|
if (fCursorVisible != visible && LockParallelAccess()) {
|
||||||
// NOTE: _CursorFrame() will
|
// NOTE: _CursorFrame() will
|
||||||
// return an invalid rect if
|
// return an invalid rect if
|
||||||
// fCursorVisible == false!
|
// fCursorVisible == false!
|
||||||
@@ -180,6 +182,8 @@ HWInterface::SetCursorVisible(bool visible)
|
|||||||
_RestoreCursorArea();
|
_RestoreCursorArea();
|
||||||
Invalidate(r);
|
Invalidate(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnlockParallelAccess();
|
||||||
}
|
}
|
||||||
fFloatingOverlaysLock.Unlock();
|
fFloatingOverlaysLock.Unlock();
|
||||||
}
|
}
|
||||||
@@ -220,12 +224,11 @@ HWInterface::MoveCursorTo(float x, float y)
|
|||||||
BPoint p(x, y);
|
BPoint p(x, y);
|
||||||
if (p != fCursorLocation) {
|
if (p != fCursorLocation) {
|
||||||
// unhide cursor if it is obscured only
|
// unhide cursor if it is obscured only
|
||||||
if (fCursorObscured) {
|
if (fCursorObscured)
|
||||||
SetCursorVisible(true);
|
SetCursorVisible(true);
|
||||||
}
|
|
||||||
IntRect oldFrame = _CursorFrame();
|
IntRect oldFrame = _CursorFrame();
|
||||||
fCursorLocation = p;
|
fCursorLocation = p;
|
||||||
if (fCursorVisible) {
|
if (fCursorVisible && LockParallelAccess()) {
|
||||||
// Invalidate and _DrawCursor would not draw
|
// Invalidate and _DrawCursor would not draw
|
||||||
// anything if the cursor is hidden
|
// anything if the cursor is hidden
|
||||||
// (invalid cursor frame), but explicitly
|
// (invalid cursor frame), but explicitly
|
||||||
@@ -242,6 +245,8 @@ HWInterface::MoveCursorTo(float x, float y)
|
|||||||
Invalidate(oldFrame);
|
Invalidate(oldFrame);
|
||||||
Invalidate(newFrame);
|
Invalidate(newFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnlockParallelAccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fFloatingOverlaysLock.Unlock();
|
fFloatingOverlaysLock.Unlock();
|
||||||
|
|||||||
Reference in New Issue
Block a user