aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mac.m50
1 files changed, 26 insertions, 24 deletions
diff --git a/src/mac.m b/src/mac.m
index 090dd0f..54aaf02 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -1188,36 +1188,38 @@ dispatchClientEvent(PuglWorld* world, NSEvent* ev)
PuglStatus
puglUpdate(PuglWorld* world, const double timeout)
{
- NSDate* date =
- ((timeout < 0) ? [NSDate distantFuture]
- : [NSDate dateWithTimeIntervalSinceNow:timeout]);
-
- for (NSEvent* ev = NULL;
- (ev = [world->impl->app nextEventMatchingMask:NSAnyEventMask
- untilDate:date
- inMode:NSDefaultRunLoopMode
- dequeue:YES]);) {
- if ([ev type] == NSApplicationDefined && [ev subtype] == PUGL_CLIENT) {
- dispatchClientEvent(world, ev);
- }
+ @autoreleasepool {
+ NSDate* date =
+ ((timeout < 0) ? [NSDate distantFuture]
+ : [NSDate dateWithTimeIntervalSinceNow:timeout]);
+
+ for (NSEvent* ev = NULL;
+ (ev = [world->impl->app nextEventMatchingMask:NSAnyEventMask
+ untilDate:date
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES]);) {
+ if ([ev type] == NSApplicationDefined && [ev subtype] == PUGL_CLIENT) {
+ dispatchClientEvent(world, ev);
+ }
- [world->impl->app sendEvent:ev];
+ [world->impl->app sendEvent:ev];
- if (timeout < 0) {
- // Now that we've waited and got an event, set the date to now to
- // avoid looping forever
- date = [NSDate date];
+ if (timeout < 0) {
+ // Now that we've waited and got an event, set the date to now to avoid
+ // looping forever
+ date = [NSDate date];
+ }
}
- }
- for (size_t i = 0; i < world->numViews; ++i) {
- PuglView* const view = world->views[i];
+ for (size_t i = 0; i < world->numViews; ++i) {
+ PuglView* const view = world->views[i];
- if ([[view->impl->drawView window] isVisible]) {
- puglDispatchSimpleEvent(view, PUGL_UPDATE);
- }
+ if ([[view->impl->drawView window] isVisible]) {
+ puglDispatchSimpleEvent(view, PUGL_UPDATE);
+ }
- [view->impl->drawView displayIfNeeded];
+ [view->impl->drawView displayIfNeeded];
+ }
}
return PUGL_SUCCESS;