Browse Source

fixed hanging of MainLoop.add (closes #10308)

Aleksandr Kuzmenko 4 years ago
parent
commit
4619b95462
2 changed files with 4 additions and 3 deletions
  1. 1 0
      extra/CHANGES.txt
  2. 3 3
      std/haxe/MainLoop.hx

+ 1 - 0
extra/CHANGES.txt

@@ -3,6 +3,7 @@
 	Bugfixes:
 	Bugfixes:
 
 
 	all : fixed errors on final vars modification with `+=`, `*=` etc operations (#10325)
 	all : fixed errors on final vars modification with `+=`, `*=` etc operations (#10325)
+	all : fixed hanging of MainLoop.add on threaded targets (#10308)
 	js : fixed IntMap for keys greater than 2^31 (#10316)
 	js : fixed IntMap for keys greater than 2^31 (#10316)
 	js : workaround to fix sourcemaps on Firefox in Windows (#10217)
 	js : workaround to fix sourcemaps on Firefox in Windows (#10217)
 	hl : add clipboard support in hl 1.12 (#10320)
 	hl : add clipboard support in hl 1.12 (#10320)

+ 3 - 3
std/haxe/MainLoop.hx

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