fix(playable): close release validation lifecycle gaps
This commit is contained in:
@@ -203,10 +203,24 @@ func valid_config() -> Dictionary:
|
||||
"resolution": [1280, 720], "loops": 1, "timeout_seconds": 900,
|
||||
}
|
||||
|
||||
func test_probe_releases_old_registries() -> void:
|
||||
var observer := Probe.new()
|
||||
for i in range(30):
|
||||
var registry := FakeFx.new()
|
||||
var reference: WeakRef = weakref(registry)
|
||||
observer.watch_local(registry, "fx_spawned", "fx_spawned")
|
||||
observer.watch_local(registry, "fx_finished", "fx_finished")
|
||||
check(observer.bound_count() == 2, "probe prunes old scene bindings")
|
||||
registry = null
|
||||
check(reference.get_ref() == null, "probe does not retain the old scene's effect registry")
|
||||
observer.disconnect_all()
|
||||
observer.free()
|
||||
|
||||
func run() -> void:
|
||||
MapCoord.set_base(Vector2.ZERO)
|
||||
test_config_contract()
|
||||
test_report_contract()
|
||||
test_probe_releases_old_registries()
|
||||
test_happy_path()
|
||||
test_gameplay_not_allowed()
|
||||
test_absent_slot_fails_without_select()
|
||||
|
||||
@@ -77,7 +77,7 @@ func snapshot() -> Dictionary:
|
||||
|
||||
func disconnect_all() -> void:
|
||||
for entry in _connections:
|
||||
var source: Object = entry.source
|
||||
var source: Object = entry.source.get_ref()
|
||||
var signal_name: String = entry.signal
|
||||
var callback: Callable = entry.callback
|
||||
if source != null and is_instance_valid(source) and source.has_signal(signal_name) \
|
||||
@@ -86,15 +86,24 @@ func disconnect_all() -> void:
|
||||
_connections.clear()
|
||||
|
||||
func bound_count() -> int:
|
||||
_prune_connections()
|
||||
return _connections.size()
|
||||
|
||||
func _prune_connections() -> void:
|
||||
for i in range(_connections.size() - 1, -1, -1):
|
||||
if _connections[i].source.get_ref() == null:
|
||||
_connections.remove_at(i)
|
||||
|
||||
func _exit_tree() -> void:
|
||||
disconnect_all()
|
||||
|
||||
func _bind(source: Object, signal_name: String, callback: Callable) -> void:
|
||||
# Registries are RefCounted and own parsed effect caches. Observing a scene
|
||||
# must not keep it alive after reconnect; discard dead bindings on rebind.
|
||||
_prune_connections()
|
||||
if source.has_signal(signal_name) and not source.is_connected(signal_name, callback):
|
||||
source.connect(signal_name, callback)
|
||||
_connections.append({"source": source, "signal": signal_name, "callback": callback})
|
||||
_connections.append({"source": weakref(source), "signal": signal_name, "callback": callback})
|
||||
|
||||
func _emit(kind: String, payload := {}, actor_vid := 0, target_vid := 0) -> void:
|
||||
var data: Dictionary = payload.duplicate(true)
|
||||
|
||||
Reference in New Issue
Block a user