summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-05 22:26:38 +0100
committerBjørn Lindeijer <bjorn@lindeijer.nl>2008-12-05 22:30:19 +0100
commit06d0205bab253ec5d01e8483ab639a092fe117c5 (patch)
tree480a2f510f189d8d3a64a99b1eb94c8b5d1ca764
parent6ac9c3bce62a8fc79e23477417188108f0ad9fa6 (diff)
downloadmana-06d0205bab253ec5d01e8483ab639a092fe117c5.tar.gz
mana-06d0205bab253ec5d01e8483ab639a092fe117c5.tar.bz2
mana-06d0205bab253ec5d01e8483ab639a092fe117c5.tar.xz
mana-06d0205bab253ec5d01e8483ab639a092fe117c5.zip
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...
-rw-r--r--src/gui/updatewindow.cpp4
-rw-r--r--src/utils/mutex.h13
2 files changed, 10 insertions, 7 deletions
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 6083725e..c0344b72 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -164,7 +164,7 @@ void UpdaterWindow::setProgress(float p)
void UpdaterWindow::setLabel(const std::string &str)
{
// Do delayed label text update, since Guichan isn't thread-safe
- MutexLocker lock(mLabelMutex);
+ MutexLocker lock(&mLabelMutex);
mNewLabelCaption = str;
}
@@ -410,7 +410,7 @@ void UpdaterWindow::logic()
// Synchronize label caption when necessary
{
- MutexLocker lock(mLabelMutex);
+ MutexLocker lock(&mLabelMutex);
if (mLabel->getCaption() != mNewLabelCaption)
{
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