aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backends/sdl/sdl-common.cpp4
-rw-r--r--backends/sdl/sdl.cpp4
-rw-r--r--backends/sdl/sdl_gl.cpp4
-rw-r--r--common/util.cpp9
-rw-r--r--common/util.h3
5 files changed, 14 insertions, 10 deletions
diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp
index 28e87db04b..3a261026c6 100644
--- a/backends/sdl/sdl-common.cpp
+++ b/backends/sdl/sdl-common.cpp
@@ -148,7 +148,7 @@ void OSystem_SDL_Common::copy_rect(const byte *buf, int pitch, int x, int y, int
if (_screen == NULL)
return;
- StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
+ StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
if (((uint32)buf & 3) == 0 && pitch == _screenWidth && x==0 && y==0 &&
w==_screenWidth && h==_screenHeight && _mode_flags&DF_WANT_RECT_OPTIM) {
@@ -1229,7 +1229,7 @@ void OSystem_SDL_Common::clear_overlay() {
if (!_overlayVisible)
return;
- StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
+ StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
// hide the mouse
undraw_mouse();
diff --git a/backends/sdl/sdl.cpp b/backends/sdl/sdl.cpp
index 0e2d2b42a1..8d73295be4 100644
--- a/backends/sdl/sdl.cpp
+++ b/backends/sdl/sdl.cpp
@@ -210,7 +210,7 @@ void OSystem_SDL::hotswap_gfx_mode() {
void OSystem_SDL::update_screen() {
assert(_hwscreen != NULL);
- StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
+ StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
// If the shake position changed, fill the dirty area with blackness
if (_currentShakePos != _newShakePos) {
@@ -336,7 +336,7 @@ void OSystem_SDL::update_screen() {
uint32 OSystem_SDL::property(int param, Property *value) {
- StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
+ StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
if (param == PROP_TOGGLE_FULLSCREEN) {
assert(_hwscreen != 0);
diff --git a/backends/sdl/sdl_gl.cpp b/backends/sdl/sdl_gl.cpp
index b671601494..a7bea1c9f0 100644
--- a/backends/sdl/sdl_gl.cpp
+++ b/backends/sdl/sdl_gl.cpp
@@ -348,7 +348,7 @@ void OSystem_SDL_OpenGL::hotswap_gfx_mode() {
void OSystem_SDL_OpenGL::update_screen() {
- StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
+ StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
// If the shake position changed, fill the dirty area with blackness
if (_currentShakePos != _newShakePos) {
@@ -548,7 +548,7 @@ bool OSystem_SDL_OpenGL::poll_event(Event *event) {
uint32 OSystem_SDL_OpenGL::property(int param, Property *value) {
- StackLock lock(_graphicsMutex); // Lock the mutex until this function ends
+ StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
if (param == PROP_TOGGLE_FULLSCREEN) {
if (!_usingOpenGL)
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();
};