diff options
author | David Robillard <d@drobilla.net> | 2020-03-08 15:21:39 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-03-08 15:40:41 +0100 |
commit | ab21ada7abb8f276a14dbb63e32ce2774456bb1b (patch) | |
tree | 914224b691d49a3f6e787687437f328a8131dfeb | |
parent | 6a8eae83edcf02c12149782c1bcbc95d69257594 (diff) | |
download | pugl-ab21ada7abb8f276a14dbb63e32ce2774456bb1b.tar.gz pugl-ab21ada7abb8f276a14dbb63e32ce2774456bb1b.tar.bz2 pugl-ab21ada7abb8f276a14dbb63e32ce2774456bb1b.zip |
Mac: Prevent indefinite blocking of puglDispatchEvents
-rw-r--r-- | pugl/detail/mac.m | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/pugl/detail/mac.m b/pugl/detail/mac.m index f26cb9e..da1ab35 100644 --- a/pugl/detail/mac.m +++ b/pugl/detail/mac.m @@ -927,11 +927,20 @@ puglWaitForEvent(PuglView* view) PUGL_API PuglStatus puglDispatchEvents(PuglWorld* world) { + const NSTimeInterval startTime = [[NSProcessInfo processInfo] systemUptime]; + for (NSEvent* ev = NULL; (ev = [world->impl->app nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES]);) { + + if ([ev timestamp] > startTime) { + // Event is later, put it back for the next iteration and return + [world->impl->app postEvent:ev atStart:true]; + break; + } + [world->impl->app sendEvent: ev]; } |