浏览代码

RemoteConsole: prevent remove during iteration on close

Yuxiao Mao 6 月之前
父节点
当前提交
7c715cb0b9
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      hrt/impl/RemoteConsole.hx

+ 5 - 2
hrt/impl/RemoteConsole.hx

@@ -79,9 +79,12 @@ class RemoteConsole {
 			sock.close();
 			sock = null;
 		}
-		for( s in connections )
-			s.close();
+		// prevent remove during iteration by c.close
+		var prevConnections = connections;
 		connections = [];
+		for( c in prevConnections ) {
+			c.close();
+		}
 		onClose();
 	}