Skip to content

Commit 84a3881

Browse files
committed
Merge pull request #109442 from archhabra/godotengine_107869
Fix `GDScript::reload` leaving `reloading` as `true` on failure
2 parents 88c8efe + e7214c2 commit 84a3881

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

modules/gdscript/gdscript.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,12 @@ Error GDScript::reload(bool p_keep_state) {
755755
has_instances = instances.size();
756756
}
757757

758-
ERR_FAIL_COND_V(!p_keep_state && has_instances, ERR_ALREADY_IN_USE);
758+
// Check condition but reset flag before early return
759+
if (!p_keep_state && has_instances) {
760+
reloading = false; // Reset flag before returning
761+
762+
ERR_FAIL_V_MSG(ERR_ALREADY_IN_USE, "Cannot reload script while instances exist.");
763+
}
759764

760765
String basedir = path;
761766

0 commit comments

Comments
 (0)