changeset 340:eff674cb4935

Test fix for Mark's dw_main_sleep() hang.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 11 Apr 2003 09:25:30 +0000
parents 4482dd0bb87d
children 503d1ac958bb
files gtk/dw.c
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Thu Apr 10 12:37:28 2003 +0000
+++ b/gtk/dw.c	Fri Apr 11 09:25:30 2003 +0000
@@ -889,21 +889,32 @@
 void dw_main_sleep(int milliseconds)
 {
 	struct timeval tv, start;
+	pthread_t curr = pthread_self();
 
 	gettimeofday(&start, NULL);
 
-	if(_dw_thread == (pthread_t)-1 || _dw_thread == pthread_self())
-	{
+	if(_dw_thread == (pthread_t)-1 || _dw_thread == curr)
+	{
+		pthread_t orig = _dw_thread;
+
 		gettimeofday(&tv, NULL);
 
 		while(((tv.tv_sec - start.tv_sec)*1000) + ((tv.tv_usec - start.tv_usec)/1000) <= milliseconds)
 		{
-			gdk_threads_enter();
+			if(orig == (pthread_t)-1)
+			{
+				gdk_threads_enter();
+				_dw_thread = curr;
+			}
 			if(gtk_events_pending())
 				gtk_main_iteration();
 			else
 				_dw_msleep(1);
-			gdk_threads_leave();
+			if(orig == (pthread_t)-1)
+			{
+				_dw_thread = orig;
+				gdk_threads_leave();
+			}
 			gettimeofday(&tv, NULL);
 		}
 	}