Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(583)

Unified Diff: runtime/bin/timer_impl.dart

Issue 8346030: Fixed NullPointerException in Timer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/tests/dart/src/TimerCancel1Test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/timer_impl.dart
diff --git a/runtime/bin/timer_impl.dart b/runtime/bin/timer_impl.dart
index 9910c4dd30e904bfb3b593dbe13483c8dcf6cd83..097e168ec6b50106354dfe3b4877890e86bd4c19 100644
--- a/runtime/bin/timer_impl.dart
+++ b/runtime/bin/timer_impl.dart
@@ -93,8 +93,10 @@ class _Timer implements Timer {
void _notifyEventHandler() {
if (_timers.firstEntry() === null) {
- EventHandler._sendData(-1, _receivePort, _NO_TIMER);
- _shutdownTimerHandler();
+ if (_receivePort != null) {
+ EventHandler._sendData(-1, _receivePort, _NO_TIMER);
+ _shutdownTimerHandler();
+ }
} else {
EventHandler._sendData(-1,
_receivePort,
@@ -113,16 +115,15 @@ class _Timer implements Timer {
int currentTime = (new Date.now()).value + _TIMER_JITTER;
DoubleLinkedQueueEntry<_Timer> entry = _timers.firstEntry();
- DoubleLinkedQueueEntry<_Timer> current;
while (entry !== null) {
- current = entry;
- _Timer timer = current.element;
- entry = entry.nextEntry();
+ _Timer timer = entry.element;
if (timer._wakeupTime <= currentTime) {
- current.remove();
- (current.element._callback)(current.element);
- if (current.element._repeating) {
- current.element._advanceWakeupTime();
+ entry.remove();
+ timer._callback(timer);
+ // Always process the event with the earliest wakeupTime first.
+ entry = _timers.firstEntry();
+ if (timer._repeating) {
+ timer._advanceWakeupTime();
timer._addTimerToList();
_notifyEventHandler();
}
« no previous file with comments | « no previous file | runtime/tests/dart/src/TimerCancel1Test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698