Browse Source

fixed hanging of MainLoop.add (closes #10308)

Aleksandr Kuzmenko 4 years ago
parent
commit
d05ba02a19
1 changed files with 3 additions and 3 deletions
  1. 3 3
      std/haxe/MainLoop.hx

+ 3 - 3
std/haxe/MainLoop.hx

@@ -110,11 +110,11 @@ class MainLoop {
 	static function injectIntoEventLoop(waitMs:Int) {
 		#if (target.threaded && !cppia)
 			mutex.acquire();
-			if(eventLoopHandler != null) {
-				mainThread.events.cancel(eventLoopHandler);
-			}
 			eventLoopHandler = mainThread.events.repeat(
 				() -> {
+					if(eventLoopHandler != null) {
+						mainThread.events.cancel(eventLoopHandler);
+					}
 					var wait = tick();
 					if(hasEvents()) {
 						injectIntoEventLoop(Std.int(wait * 1000));