changeset 14245:9f8dd2ab8135 draft

(svn r18796) -Fix [FS#3521]: [SDL] possible deadlock when killing OpenTTD while starting it
author rubidium <rubidium@openttd.org>
date Wed, 13 Jan 2010 21:34:48 +0000
parents 29d92fedf402
children bb74cb757ae4
files src/video/sdl_v.cpp
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/sdl_v.cpp
+++ b/src/video/sdl_v.cpp
@@ -112,8 +112,11 @@
 
 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 @@
 			if (!_draw_threaded) {
 				_draw_mutex->EndCritical();
 				delete _draw_mutex;
+			} else {
+				/* Wait till the draw mutex has started itself. */
+				_draw_mutex->WaitForSignal();
 			}
 		}
 	}