Repository navigation
Fix object_set_instance being wrongly called for built-in wrapped classes - #668
Conversation
|
I think this looks good but I believe @reduz needs to confirm our findings first, we're trying to piece together how this is supposed to work while he designed the Godot side of it and should be able to tell us if our theory is correct. If it is, this fix looks sound to me. |
|
I still see errors after applying adbbf1a. I think, these lines: if (extension_class) {
godot::internal::gdn_interface->object_set_instance(_owner, extension_class, this);
}
godot::internal::gdn_interface->object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks());Should be: if (extension_class) {
godot::internal::gdn_interface->object_set_instance(_owner, extension_class, this);
godot::internal::gdn_interface->object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks());
} |
|
Here's the minimal reproducible example for the error below: Scene tree:
Extension code: class TestContainer : public Node
{
GDCLASS(TestContainer, Node);
public:
static void _bind_methods() {}
void _ready() override
{
WARN_PRINT("TestContainer::_ready()");
get_node<Node>("Node"); // <-----------------------------------
}
}; |
|
I haven't touched this code in a while, but from what I can gather the change is good. The issue mentioned by @saki7 seems unrelated to this change, so IMO it doesn't need to be fixed in this PR. For what I know the built-in classes still need the instance binding since that's what is used in the godot-cpp side. |
|
Thanks, let's merge then. @saki7 Can you open a dedicated issue for the bug you're running into? |
|
Thanks! |
This used to cause errors to be printed out, such as:
This happened for all objects created from a Godot built-in class. In such cases, we are not supposed to set the
_extensionand_extension_instanceproperties of the associated GodotObject, whichobject_set_instancedoes.For this, I renamed
_get_classto_get_extension_class, which will returnnullptrfor all built-in classes, and the extension class name for extension-only classes.Also, I remove
CHECK_CLASS_CONSTRUCTOR, it is unused since my recent constructor rework.