summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-13 21:34:48 +0000
committerrubidium <rubidium@openttd.org>2010-01-13 21:34:48 +0000
commit7aeccb9bd09c9c0075e777e86e1a44e6bcfa6afc (patch)
tree6a68f151d8f3bfed23e61b9833450ed820f03b12 /src/video
parentf43646cd7d361899c09e90b97634352216dca203 (diff)
downloadopenttd-7aeccb9bd09c9c0075e777e86e1a44e6bcfa6afc.tar.xz
(svn r18796) -Fix [FS#3521]: [SDL] possible deadlock when killing OpenTTD while starting it
Diffstat (limited to 'src/video')
-rw-r--r--src/video/sdl_v.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/video/sdl_v.cpp b/src/video/sdl_v.cpp
index 70684a0d3..61f37a622 100644
--- a/src/video/sdl_v.cpp
+++ b/src/video/sdl_v.cpp
@@ -112,8 +112,11 @@ static void DrawSurfaceToScreen()
static void DrawSurfaceToScreenThread(void *)
{
- /* First wait till we 'may' start */
+ /* First tell the main thread we're started */
_draw_mutex->BeginCritical();
+ _draw_mutex->SendSignal();
+
+ /* Now wait for the first thing to draw! */
_draw_mutex->WaitForSignal();
while (_draw_continue) {
@@ -516,6 +519,9 @@ void VideoDriver_SDL::MainLoop()
if (!_draw_threaded) {
_draw_mutex->EndCritical();
delete _draw_mutex;
+ } else {
+ /* Wait till the draw mutex has started itself. */
+ _draw_mutex->WaitForSignal();
}
}
}