From 032f7659014d265a3c34765da2f277b7b0f32691 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 5 Dec 2008 22:26:38 +0100 Subject: Fixed MutexLocker to not work on a copy The Mutex class wasn't meant to be copied around. Silly last minute refactorings leading to untested code... --- src/utils/mutex.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/utils') diff --git a/src/utils/mutex.h b/src/utils/mutex.h index 6c35987c..62c6b4e1 100644 --- a/src/utils/mutex.h +++ b/src/utils/mutex.h @@ -40,6 +40,9 @@ public: void unlock(); private: + Mutex(const Mutex&); // prevent copying + Mutex& operator=(const Mutex&); + SDL_mutex *mMutex; }; @@ -49,11 +52,11 @@ private: class MutexLocker { public: - MutexLocker(Mutex mutex); + MutexLocker(Mutex *mutex); ~MutexLocker(); private: - Mutex mMutex; + Mutex *mMutex; }; @@ -80,15 +83,15 @@ inline void Mutex::unlock() } -inline MutexLocker::MutexLocker(Mutex mutex): +inline MutexLocker::MutexLocker(Mutex *mutex): mMutex(mutex) { - mMutex.lock(); + mMutex->lock(); } inline MutexLocker::~MutexLocker() { - mMutex.unlock(); + mMutex->unlock(); } #endif // TMW_MUTEX_H -- cgit v1.2.3-70-g09d2