From ce9d154957d8843a07a32730e7fd3400948e164d Mon Sep 17 00:00:00 2001 From: Max Horn Date: Sat, 5 Jul 2003 15:28:28 +0000 Subject: fixed stack lock at startup svn-id: r8779 --- common/util.cpp | 9 ++++++--- common/util.h | 3 ++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'common') diff --git a/common/util.cpp b/common/util.cpp index 548fcb6a41..8920453bd7 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -166,7 +166,10 @@ uint RandomSource::getRandomNumberRng(uint min, uint max) { return getRandomNumber(max - min) + min; } -StackLock::StackLock(OSystem::MutexRef mutex) : _mutex(mutex) { +StackLock::StackLock(OSystem::MutexRef mutex, OSystem *syst) + : _mutex(mutex), _syst(syst) { + if (syst == 0) + _syst = g_system; lock(); } @@ -175,12 +178,12 @@ StackLock::~StackLock() { } void StackLock::lock() { - assert(g_system); + assert(_syst); g_system->lock_mutex(_mutex); } void StackLock::unlock() { - assert(g_system); + assert(_syst); g_system->unlock_mutex(_mutex); } diff --git a/common/util.h b/common/util.h index 8c0409e0ef..3a77445567 100644 --- a/common/util.h +++ b/common/util.h @@ -80,10 +80,11 @@ public: */ class StackLock { OSystem::MutexRef _mutex; + OSystem *_syst; void lock(); void unlock(); public: - StackLock(OSystem::MutexRef mutex); + StackLock(OSystem::MutexRef mutex, OSystem *syst = 0); ~StackLock(); }; -- cgit v1.2.3