⛏️ index : haiku.git

author Augustin Cavalier <waddlesplash@gmail.com> 2025-11-29 19:20:42.0 -05:00:00
committer Augustin Cavalier <waddlesplash@gmail.com> 2025-11-29 19:20:42.0 -05:00:00
commit
1f58862893cfb7cb6ec50b17913500cbf5e60edc [patch]
tree
e67fbc1b9c187cc0e8cc39136ddea3656042a163
parent
0ab44682c99358698ba38b89a1c61913f2ef9325
download
1f58862893cfb7cb6ec50b17913500cbf5e60edc.tar.gz

app_server: Acquire the window lock in Set*Cursor.

SetScreenMode() and other methods around here also acquire it
in this way.

Adjust one place in ServerApp that would cause a lock-order-inversion
otherwise.

Should fix #19837.

Diff

 src/servers/app/Desktop.cpp   | 4 ++++
 src/servers/app/ServerApp.cpp | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/servers/app/Desktop.cpp b/src/servers/app/Desktop.cpp
index 788edbe..d36b93f 100644
--- a/src/servers/app/Desktop.cpp
+++ b/src/servers/app/Desktop.cpp
@@ -693,6 +693,8 @@
void
Desktop::SetCursor(ServerCursor* newCursor)
{
	AutoWriteLocker _(fWindowLock);

	if (newCursor == NULL)
		newCursor = fCursorManager.GetCursor(B_CURSOR_ID_SYSTEM_DEFAULT);

@@ -716,6 +718,8 @@
void
Desktop::SetManagementCursor(ServerCursor* newCursor)
{
	AutoWriteLocker _(fWindowLock);

	if (newCursor == fManagementCursor)
		return;

diff --git a/src/servers/app/ServerApp.cpp b/src/servers/app/ServerApp.cpp
index 530ce75..69cd0a0 100644
--- a/src/servers/app/ServerApp.cpp
+++ b/src/servers/app/ServerApp.cpp
@@ -1080,10 +1080,10 @@

			fAppCursor.SetTo(fDesktop->GetCursorManager().FindCursor(token), false);

			fDesktop->GetCursorManager().Unlock();

			if (_HasWindowUnderMouse())
				fDesktop->SetCursor(CurrentCursor());

			fDesktop->GetCursorManager().Unlock();

			if (sync) {
				// The application is expecting a reply