瀏覽代碼

Merge pull request #109442 from archhabra/godotengine_107869

Fix `GDScript::reload` leaving `reloading` as `true` on failure
Thaddeus Crews 2 周之前
父節點
當前提交
84a3881120
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      modules/gdscript/gdscript.cpp

+ 6 - 1
modules/gdscript/gdscript.cpp

@@ -755,7 +755,12 @@ Error GDScript::reload(bool p_keep_state) {
 		has_instances = instances.size();
 		has_instances = instances.size();
 	}
 	}
 
 
-	ERR_FAIL_COND_V(!p_keep_state && has_instances, ERR_ALREADY_IN_USE);
+	// Check condition but reset flag before early return
+	if (!p_keep_state && has_instances) {
+		reloading = false; // Reset flag before returning
+
+		ERR_FAIL_V_MSG(ERR_ALREADY_IN_USE, "Cannot reload script while instances exist.");
+	}
 
 
 	String basedir = path;
 	String basedir = path;