Godot Engine – Multi-platform 2D and 3D game engine
GDScript make error due to SIOF destruction more clear
HolonProduction087f5cb313c3
diff --git a/modules/gdscript/gdscript_vm.cpp b/modules/gdscript/gdscript_vm.cppindex 04c2463d417..0699d9c07cb 100644--- a/modules/gdscript/gdscript_vm.cpp+++ b/modules/gdscript/gdscript_vm.cpp@@ -1356,7 +1356,17 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_aGD_ERR_BREAK(!gdscript);int index = _code_ptr[ip + 3];- GD_ERR_BREAK(index < 0 || index >= gdscript->static_variables.size());+ if (unlikely(index < 0 || index >= gdscript->static_variables.size())) {+#ifdef DEBUG_ENABLED+ if (GDScriptLanguage::get_singleton()->finishing) {+ // Just assume it's SIOF. There is a tiny possibility that something else is causing this (e.g. bug, reload).+ err_text = vformat("Static variable does not exist anymore. Since the order in which static variables are destructed is arbitrary, consider emptying objects from them in a well-defined order manually before shutdown.");+ } else {+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition 'index < 0 || index >= gdscript->static_variables.size()' is true. Breaking..:");+ }+#endif+ OPCODE_BREAK;+ }gdscript->static_variables.write[index] = *value;@@ -1374,7 +1384,18 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_aGD_ERR_BREAK(!gdscript);int index = _code_ptr[ip + 3];- GD_ERR_BREAK(index < 0 || index >= gdscript->static_variables.size());++ if (unlikely(index < 0 || index >= gdscript->static_variables.size())) {+#ifdef DEBUG_ENABLED+ if (GDScriptLanguage::get_singleton()->finishing) {+ // Just assume it's SIOF. There is a tiny possibility that something else is causing this (e.g. bug, reload).+ err_text = vformat("Static variable does not exist anymore. Since the order in which static variables are destructed is arbitrary, consider emptying objects from them in a well-defined order manually before shutdown.");+ } else {+ _err_print_error(FUNCTION_STR, __FILE__, __LINE__, "Condition 'index < 0 || index >= gdscript->static_variables.size()' is true. Breaking..:");+ }+#endif+ OPCODE_BREAK;+ }*target = gdscript->static_variables[index];