godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.74k stars 574 forks source link

Crash after add node with custom class to scene #121

Closed thankjura closed 6 years ago

thankjura commented 6 years ago

I can't add node with custom class to scene. Problem appeared in the last commit.

ERROR: get: Condition ' !res ' is true. returned: res At: core/hash_map.h:306. handle_crash: Program crashed with signal 11 Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues [1] /lib64/libc.so.6(+0x35fc0) [0x7f12e3668fc0] (??:0) [2] NativeScriptLanguage::get_instance_binding_data(int, Object) (??:?) [3] godot(godot_nativescript_get_instance_binding_data+0x26) [0x16f6536] (??:?) [4] godot::_godot_icall_Object(godot_method_bind, godot::Object const) (??:0) [5] Spr::_ready() (??:0) [6] godot_variant godot::wrapped_method<Spr, void>(void, void, void*, int, godot_variant*) (??:0) [7] NativeScriptInstance::_ml_call_reversed(NativeScriptDesc, StringName const&, Variant const, int) (??:?) [8] NativeScriptInstance::call_multilevel_reversed(StringName const&, Variant const, int) (??:?) [9] Node::_notification(int) (??:?) [10] Node::_notificationv(int, bool) (??:?) [11] CanvasItem::_notificationv(int, bool) (??:?) [12] Node2D::_notificationv(int, bool) (??:?) [13] Object::notification(int, bool) (??:?) [14] Node::_propagate_ready() (??:?) [15] Node::_set_tree(SceneTree) (??:?) [16] Node::_add_child_nocheck(Node, StringName const&) (??:?) [17] Node::add_child(Node*, bool) (??:?)

Demo: cpp-inst.zip

karroffel commented 6 years ago

Will check!

karroffel commented 6 years ago

@thankjura Just pushed a fix, can you try it out?

thankjura commented 6 years ago

Yes. It fixes, thanks

thankjura commented 6 years ago

Hm. register_property do not work:

I add _register_methods() { register_property<PlayerHenry, Vector2> ("main/test", &PlayerHenry::test, Vector2(10,20)); }

_ready() { Godot::print(test); }

output: 0,0

image

karroffel commented 6 years ago

Will take a look

karroffel commented 6 years ago

I can't reproduce the issue, it works as expected for me :/

thankjura commented 6 years ago

If I change default value in editor - bug disapper.

thankjura commented 6 years ago

cpp-export.zip

karroffel commented 6 years ago

Actually I don't think that's a bug. You are supposed to have initialized the variable with the default value. If the property never gets set from the outside then the value will never be different than the one it already has - which after initialization is 0,0.

So that's not a bug :D