Merge pull request #116711 from dalexeev/gds-fix-coroutine-clearing
GDScript: Fix interrupted coroutines not clearing
This commit is contained in:
commit
017e690e47
3 changed files with 42 additions and 0 deletions
|
|
@ -277,5 +277,6 @@ GDScriptFunctionState::~GDScriptFunctionState() {
|
|||
MutexLock lock(GDScriptLanguage::singleton->mutex);
|
||||
scripts_list.remove_from_list();
|
||||
instances_list.remove_from_list();
|
||||
_clear_stack();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
# GH-116706
|
||||
|
||||
class Instance:
|
||||
func _init() -> void:
|
||||
print("Instance _init")
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_PREDELETE:
|
||||
print("Instance predelete")
|
||||
|
||||
class LocalOwner:
|
||||
signal never_emitted()
|
||||
|
||||
func _init() -> void:
|
||||
print("LocalOwner _init")
|
||||
|
||||
func _notification(what: int) -> void:
|
||||
if what == NOTIFICATION_PREDELETE:
|
||||
print("LocalOwner predelete")
|
||||
|
||||
func interrupted_coroutine() -> void:
|
||||
print("interrupted_coroutine begin")
|
||||
var _instance := Instance.new()
|
||||
await never_emitted
|
||||
print("interrupted_coroutine end")
|
||||
|
||||
func test():
|
||||
print("test begin")
|
||||
var local_owner := LocalOwner.new()
|
||||
@warning_ignore("missing_await")
|
||||
local_owner.interrupted_coroutine()
|
||||
local_owner = null
|
||||
print("test end")
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
GDTEST_OK
|
||||
test begin
|
||||
LocalOwner _init
|
||||
interrupted_coroutine begin
|
||||
Instance _init
|
||||
LocalOwner predelete
|
||||
Instance predelete
|
||||
test end
|
||||
Loading…
Add table
Add a link
Reference in a new issue