From ce0bf30189d46cb2c7f1ac667de43263afc00e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesu=CC=81s=20A=2E=20A=CC=81lvarez?= Date: Tue, 31 May 2016 23:16:07 +0200 Subject: [PATCH] WaitForNextTick: make closer to cocoa version --- Mini vMac/MYOSGLUE.m | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Mini vMac/MYOSGLUE.m b/Mini vMac/MYOSGLUE.m index 30bc085..7dc69a9 100644 --- a/Mini vMac/MYOSGLUE.m +++ b/Mini vMac/MYOSGLUE.m @@ -1704,10 +1704,9 @@ GLOBALFUNC blnr ExtraTimeNotOver(void) { GLOBALPROC WaitForNextTick(void) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSRunLoop *mainRunLoop = [NSRunLoop mainRunLoop]; + NSDate *until = [NSDate distantPast]; label_retry: - while (ExtraTimeNotOver()) { - [mainRunLoop runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceReferenceDate:NextTickChangeTime]]; - } + [mainRunLoop runMode:NSDefaultRunLoopMode beforeDate:until]; CheckForSavedTasks(); @@ -1717,6 +1716,12 @@ label_retry: if (CurSpeedStopped) { DoneWithDrawingForTick(); + until = [NSDate distantFuture]; + goto label_retry; + } + + if (ExtraTimeNotOver()) { + until = [NSDate dateWithTimeIntervalSinceReferenceDate:NextTickChangeTime]; goto label_retry; }