# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1050053130 0 # Node ID eff674cb49354fe1b65d011291f45f93225274b3 # Parent 4482dd0bb87d406fac144011b98f13815bd1bf8d Test fix for Mark's dw_main_sleep() hang. diff -r 4482dd0bb87d -r eff674cb4935 gtk/dw.c --- 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); } }