Fix Godot 4.7 typed array crash: add freed-object filtering in PropertyPool and PerObjectHistory
This commit is contained in:
@@ -11,8 +11,14 @@ func _init(p_history_size: int):
|
||||
_history_size = p_history_size
|
||||
|
||||
func subjects() -> Array[Object]:
|
||||
# Filter out freed objects — Godot 4.7 stricter typed arrays
|
||||
# reject invalid references and crash the engine.
|
||||
var valid := []
|
||||
for o in _data.keys():
|
||||
if is_instance_valid(o):
|
||||
valid.append(o)
|
||||
var result := [] as Array[Object]
|
||||
result.assign(_data.keys())
|
||||
result.assign(valid)
|
||||
return result
|
||||
|
||||
func is_auth(tick: int, subject: Object) -> bool:
|
||||
|
||||
@@ -49,8 +49,14 @@ func get_properties_of(subject: Object) -> Array[NodePath]:
|
||||
return properties
|
||||
|
||||
func get_subjects() -> Array[Object]:
|
||||
# Filter out freed objects — Godot 4.7 stricter typed arrays
|
||||
# reject invalid references and crash the engine.
|
||||
var valid := []
|
||||
for s in _properties_by_subject.keys():
|
||||
if is_instance_valid(s):
|
||||
valid.append(s)
|
||||
var subjects := [] as Array[Object]
|
||||
subjects.assign(_properties_by_subject.keys())
|
||||
subjects.assign(valid)
|
||||
return subjects
|
||||
|
||||
func is_empty() -> bool:
|
||||
|
||||
Reference in New Issue
Block a user