Merge pull request #61003 from vnen/gdscript-await-stack-fix

This commit is contained in:
Rémi Verschelde 2022-05-16 14:10:29 +02:00 committed by GitHub
commit c41f62c3df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 34 deletions

View file

@ -279,7 +279,8 @@ Variant GDScriptFunctionState::resume(const Variant &p_arg) {
void GDScriptFunctionState::_clear_stack() {
if (state.stack_size) {
Variant *stack = (Variant *)state.stack.ptr();
for (int i = 0; i < state.stack_size; i++) {
// The first 3 are special addresses and not copied to the state, so we skip them here.
for (int i = 3; i < state.stack_size; i++) {
stack[i].~Variant();
}
state.stack_size = 0;
@ -300,8 +301,6 @@ GDScriptFunctionState::GDScriptFunctionState() :
}
GDScriptFunctionState::~GDScriptFunctionState() {
_clear_stack();
{
MutexLock lock(GDScriptLanguage::singleton->lock);
scripts_list.remove_from_list();