From 67d5c5a83883b5a0067d8eb9c3f28b184bb638a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Tue, 8 Apr 2008 08:12:38 +0000 Subject: [PATCH] Implemented Oliver's suggested improvement to ServerCursorReference when switching cursors. There was a race condition in case the objects was used by multiple threads, in which Cursor() could return an already destroyed object. Note: This doesn't fix a real bug or anything, the change is purely forward looking in case ServerCursorReference is ever used like that. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24862 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/app/ServerCursor.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/servers/app/ServerCursor.h b/src/servers/app/ServerCursor.h index 70493224c8..4014d5fa90 100644 --- a/src/servers/app/ServerCursor.h +++ b/src/servers/app/ServerCursor.h @@ -105,11 +105,12 @@ public: { if (fCursor == cursor) return; - if (fCursor) - fCursor->Release(); + if (cursor) + cursor->Acquire(); + ServerCursor* oldCursor = fCursor; fCursor = cursor; - if (fCursor) - fCursor->Acquire(); + if (oldCursor) + oldCursor->Release(); } ServerCursor* Cursor() const {