diff options
author | frosch <frosch@openttd.org> | 2014-02-16 21:57:22 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2014-02-16 21:57:22 +0000 |
commit | 27eede06c900abc851c3297897bf5f658164b21a (patch) | |
tree | 58fd669bcda3571b4110d6e1c975911e414a1605 | |
parent | fe03ab06e5e143fba1afb6f3389beb226583caa9 (diff) | |
download | openttd-27eede06c900abc851c3297897bf5f658164b21a.tar.xz |
(svn r26351) -Fix: Protect all VideoDriver_SDL methods with the _draw_mutex.
-rw-r--r-- | src/video/sdl_v.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp index 462989f55..cad21955d 100644 --- a/src/video/sdl_v.cpp +++ b/src/video/sdl_v.cpp @@ -817,27 +817,34 @@ void VideoDriver_SDL::MainLoop() bool VideoDriver_SDL::ChangeResolution(int w, int h) { - if (_draw_mutex != NULL) _draw_mutex->BeginCritical(); + if (_draw_mutex != NULL) _draw_mutex->BeginCritical(true); bool ret = CreateMainSurface(w, h); - if (_draw_mutex != NULL) _draw_mutex->EndCritical(); + if (_draw_mutex != NULL) _draw_mutex->EndCritical(true); return ret; } bool VideoDriver_SDL::ToggleFullscreen(bool fullscreen) { + if (_draw_mutex != NULL) _draw_mutex->BeginCritical(true); _fullscreen = fullscreen; GetVideoModes(); // get the list of available video modes - if (_num_resolutions == 0 || !CreateMainSurface(_cur_resolution.width, _cur_resolution.height)) { + bool ret = _num_resolutions != 0 && CreateMainSurface(_cur_resolution.width, _cur_resolution.height); + + if (!ret) { /* switching resolution failed, put back full_screen to original status */ _fullscreen ^= true; - return false; } - return true; + + if (_draw_mutex != NULL) _draw_mutex->EndCritical(true); + return ret; } bool VideoDriver_SDL::AfterBlitterChange() { - return CreateMainSurface(_screen.width, _screen.height); + if (_draw_mutex != NULL) _draw_mutex->BeginCritical(true); + bool ret = CreateMainSurface(_screen.width, _screen.height); + if (_draw_mutex != NULL) _draw_mutex->EndCritical(true); + return ret; } #endif /* WITH_SDL */ |