ソースを参照

fix bug when haxe.Timer.stamp() < 0, resulting in immediate run Timer (#8896)

Nicolas Cannasse 5 年 前
コミット
a378d8f781
1 ファイル変更3 行追加3 行削除
  1. 3 3
      std/haxe/MainLoop.hx

+ 3 - 3
std/haxe/MainLoop.hx

@@ -18,7 +18,7 @@ class MainEvent {
 	function new(f, p) {
 		this.f = f;
 		this.priority = p;
-		nextRun = -1;
+		nextRun = Math.NEGATIVE_INFINITY;
 	}
 
 	/**
@@ -26,7 +26,7 @@ class MainEvent {
 		If t is null, the event will be run at tick() time.
 	**/
 	public function delay(t:Null<Float>) {
-		nextRun = t == null ? -1 : haxe.Timer.stamp() + t;
+		nextRun = t == null ? Math.NEGATIVE_INFINITY : haxe.Timer.stamp() + t;
 	}
 
 	/**
@@ -169,7 +169,7 @@ class MainLoop {
 		while (e != null) {
 			var next = e.next;
 			var wt = e.nextRun - now;
-			if (e.nextRun < 0 || wt <= 0) {
+			if (wt <= 0) {
 				wait = 0;
 				e.call();
 			} else if (wait > wt)