From e7214c229bafb457a7b1622cd1ca7d6bb40fe83a Mon Sep 17 00:00:00 2001 From: Arti Chhabra Date: Fri, 8 Aug 2025 12:56:47 -0700 Subject: [PATCH] Fix the issue by resetting the reloading false first and then returning error directly instead of calling Macro Fix the review comment Fix the clang format Update as per review comment --- modules/gdscript/gdscript.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index a53c8fae6b6..0f800a228fc 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -755,7 +755,12 @@ Error GDScript::reload(bool p_keep_state) { 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;