diff options
Diffstat (limited to 'modules/gdscript')
| -rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 2 | ||||
| -rw-r--r-- | modules/gdscript/gdscript.cpp | 14 |
2 files changed, 14 insertions, 2 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 918581bc9b..613039754f 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -818,6 +818,7 @@ a = [1, 2, 3] print("a", "b", a) # Prints ab[1, 2, 3] [/codeblock] + [b]Note:[/b] Consider using [method push_error] and [method push_warning] to print error and warning messages instead of [method print]. This distinguishes them from print messages used for debugging purposes, while also displaying a stack trace when an error or warning is printed. </description> </method> <method name="print_debug" qualifiers="vararg"> @@ -891,6 +892,7 @@ [codeblock] push_error("test error") # Prints "test error" to debugger and terminal as error call [/codeblock] + [b]Note:[/b] Errors printed this way will not pause project execution. To print an error message and pause project execution in debug builds, use [code]assert(false, "test error")[/code] instead. </description> </method> <method name="push_warning"> diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 7f303a966d..3519038ae6 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2039,8 +2039,15 @@ GDScriptLanguage::~GDScriptLanguage() { } // Clear dependencies between scripts, to ensure cyclic references are broken (to avoid leaks at exit). - while (script_list.first()) { - GDScript *script = script_list.first()->self(); + SelfList<GDScript> *s = script_list.first(); + while (s) { + GDScript *script = s->self(); + // This ensures the current script is not released before we can check what's the next one + // in the list (we can't get the next upfront because we don't know if the reference breaking + // will cause it -or any other after it, for that matter- to be released so the next one + // is not the same as before). + script->reference(); + for (Map<StringName, GDScriptFunction *>::Element *E = script->member_functions.front(); E; E = E->next()) { GDScriptFunction *func = E->get(); for (int i = 0; i < func->argument_types.size(); i++) { @@ -2051,6 +2058,9 @@ GDScriptLanguage::~GDScriptLanguage() { for (Map<StringName, GDScript::MemberInfo>::Element *E = script->member_indices.front(); E; E = E->next()) { E->get().data_type.script_type_ref = Ref<Script>(); } + + s = s->next(); + script->unreference(); } singleton = NULL; |