瀏覽代碼

Fix crashing of VisualScript due to...

Attempting to move the function node to another function whose data connection is a dependency of the node the specific node being moved to a different function during changes to sequence connections.
By skipping, if the from_node is a function_node during the data connection dependencies scan.
Should fix #37991

(cherry picked from commit 5c48631509751191afc5a83e4c48075a90a38150)
Swarnim Arun 5 年之前
父節點
當前提交
83c15ff469
共有 1 個文件被更改,包括 6 次插入0 次删除
  1. 6 0
      modules/visual_script/visual_script_editor.cpp

+ 6 - 0
modules/visual_script/visual_script_editor.cpp

@@ -3126,6 +3126,7 @@ void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from,
 	{
 		List<VisualScript::DataConnection> data_connections;
 		script->get_data_connection_list(p_func_from, &data_connections);
+		int func_from_node_id = script->get_function_node_id(p_func_from);
 
 		HashMap<int, Map<int, Pair<int, int> > > connections;
 
@@ -3135,6 +3136,11 @@ void VisualScriptEditor::_move_nodes_with_rescan(const StringName &p_func_from,
 			int out_p = E->get().from_port;
 			int in_p = E->get().to_port;
 
+			// skip if the from_node is a function node
+			if (from == func_from_node_id) {
+				continue;
+			}
+
 			if (!connections.has(to))
 				connections.set(to, Map<int, Pair<int, int> >());
 			connections[to].insert(in_p, Pair<int, int>(from, out_p));