mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-28 06:27:02 +00:00
Fix for timers not working if they are created outside of a run loop.
Reviewed by me.
This commit is contained in:
+15
-2
@@ -157,6 +157,7 @@ var CPRunLoopLastNativeRunLoop = 0;
|
||||
CPDate _effectiveDate;
|
||||
|
||||
CPArray _orderedPerforms;
|
||||
int _runLoopInsuranceTimer;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -267,6 +268,12 @@ var CPRunLoopLastNativeRunLoop = 0;
|
||||
aTimer._lastNativeRunLoopsForModes = {};
|
||||
|
||||
aTimer._lastNativeRunLoopsForModes[aMode] = CPRunLoopLastNativeRunLoop;
|
||||
|
||||
if (!_runLoopInsuranceTimer)
|
||||
_runLoopInsuranceTimer = window.setNativeTimeout(function()
|
||||
{
|
||||
[self limitDateForMode:CPDefaultRunLoopMode];
|
||||
}, 0);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -277,9 +284,15 @@ var CPRunLoopLastNativeRunLoop = 0;
|
||||
//simple locking to try to prevent concurrent iterating over timers
|
||||
if (_runLoopLock)
|
||||
return;
|
||||
|
||||
|
||||
_runLoopLock = YES;
|
||||
|
||||
|
||||
if (_runLoopInsuranceTimer)
|
||||
{
|
||||
window.clearNativeTimeout(_runLoopInsuranceTimer);
|
||||
_runLoopInsuranceTimer = nil;
|
||||
}
|
||||
|
||||
var now = _effectiveDate ? [_effectiveDate laterDate:[CPDate date]] : [CPDate date],
|
||||
nextFireDate = nil,
|
||||
nextTimerFireDate = _nextTimerFireDatesForModes[aMode];
|
||||
|
||||
Reference in New Issue
Block a user