Mercurial > dwindows
diff gtk/dw.c @ 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 | 44e2bdacd8f3 |
children | 599644ca9064 |
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); } }