From 37683f849f343f93755db1727966d218f957bb89 Mon Sep 17 00:00:00 2001 From: mcmartin Date: Wed, 8 Oct 2003 01:24:35 +0000 Subject: [PATCH] Locking fixes (#504) You *must* hold the GraphicsLock when calling SetFlashRect. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1265 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 2 ++ sc2/src/sc2code/gameopt.c | 2 ++ sc2/src/sc2code/shipyard.c | 2 ++ 3 files changed, 6 insertions(+) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 28f74c971..e18250de8 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ Changes towards version 0.4: +- Patches to enforce the invariant that the GraphicsLock is held when + SetFlashRect is called (bug #504) -Michael - Major refactoring of threadlib; see doc/devel/threads -Michael - Downgraded the GraphicsLock to an ordinary Mutex -Michael - Added movie player; only movies defined are intro and ending; diff --git a/sc2/src/sc2code/gameopt.c b/sc2/src/sc2code/gameopt.c index 3cba87165..8f53234f9 100644 --- a/sc2/src/sc2code/gameopt.c +++ b/sc2/src/sc2code/gameopt.c @@ -1014,7 +1014,9 @@ Restart: } else if (CurrentMenuState.cancel) { + LockMutex (GraphicsLock); SetFlashRect ((PRECT)~0L, (FRAME)0); + UnlockMutex (GraphicsLock); pMS->ModuleFrame = 0; pMS->CurState = (BYTE)pMS->delta_item; ResumeMusic (); diff --git a/sc2/src/sc2code/shipyard.c b/sc2/src/sc2code/shipyard.c index 458f31761..38da9d81d 100644 --- a/sc2/src/sc2code/shipyard.c +++ b/sc2/src/sc2code/shipyard.c @@ -755,7 +755,9 @@ DoModifyShips (PMENU_STATE pMS) else if (cancel) { pMS->delta_item ^= MODIFY_CREW_FLAG; + LockMutex (GraphicsLock); SetFlashRect ((PRECT)~0L, (FRAME)0); + UnlockMutex (GraphicsLock); DrawMenuStateStrings (PM_CREW, SHIPYARD_CREW); } else if (select)