Mercurial > dwindows
changeset 728:55f22b39ab57
Changes to correctly set the main thread and lock the run mutex when not running a loop and when called from a callback.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 14 Mar 2011 22:25:01 +0000 |
parents | f190b5c2ce16 |
children | 6712e4211522 |
files | mac/dw.m |
diffstat | 1 files changed, 16 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mac/dw.m Mon Mar 14 21:43:28 2011 +0000 +++ b/mac/dw.m Mon Mar 14 22:25:01 2011 +0000 @@ -1937,9 +1937,9 @@ DWTID orig = DWThread; NSDate *until = [NSDate dateWithTimeIntervalSinceNow:(milliseconds/1000.0)]; - dw_mutex_lock(DWRunMutex); if(orig == (DWTID)-1) { + dw_mutex_lock(DWRunMutex); DWThread = curr; } /* Process any pending events */ @@ -1950,8 +1950,8 @@ if(orig == (DWTID)-1) { DWThread = orig; + dw_mutex_unlock(DWRunMutex); } - dw_mutex_unlock(DWRunMutex); } else { @@ -1980,9 +1980,20 @@ */ void API dw_main_iteration(void) { - dw_mutex_lock(DWRunMutex); - _dw_main_iteration([NSDate distantPast]); - dw_mutex_unlock(DWRunMutex); + DWTID curr = pthread_self(); + + if(DWThread == (DWTID)-1) + { + dw_mutex_lock(DWRunMutex); + DWThread = curr; + _dw_main_iteration([NSDate distantPast]); + DWThread = (DWTID)-1; + dw_mutex_unlock(DWRunMutex); + } + else if(DWThread == curr) + { + _dw_main_iteration([NSDate distantPast]); + } } /*