godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.22k stars 21.22k forks source link

set_deferred method is invalid #80002

Closed CodeLazier closed 1 year ago

CodeLazier commented 1 year ago

Godot version

4.2 Dev 2

System information

Win10

Issue description

An area node, and setting area.set_deferred ('monitoring', true) in gdscript,and then 4.2 Dev 1 and below are no problem. Updating to Dev2 failed, and tests found that setting other properties was also ineffective, such as Sprite2D.set_deferred('position', Vector2(100,100))

Steps to reproduce

add area node in scene write the code in _read callback

func _ready() -> void:
    area_2d.set_deferred('monitoring',true)

run,observe the node properties in the property inspector

Minimal reproduction project

test_bug.zip

kleonc commented 1 year ago

Caused by #78987, cc @RandomShaper.

CallQueue::push_set creates a Callable with the property name passed as the method. :upside_down_face: https://github.com/godotengine/godot/blob/031aa99d313ceec7cdb8263957d22cae10de0b95/core/object/message_queue.cpp#L165 Hence for such message the added check fails as object doesn't have such method: https://github.com/godotengine/godot/blob/031aa99d313ceec7cdb8263957d22cae10de0b95/core/object/message_queue.cpp#L324 https://github.com/godotengine/godot/blob/031aa99d313ceec7cdb8263957d22cae10de0b95/core/variant/callable.cpp#L128