You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
add_virtual_method with parameter crashes engine when loading editor #1580
When I regist a method with a parameter to be virtual for godot. Editor crashed when launching.
I think it is caused by empty arguments_metadata in created MethodInfo.
I tried to add vector size checking code in class_db.cpp. And crash dosen't appear.
Steps to reproduce
Regist a virtual method by calling: ClassDB::add_virtual_method("TestClass", MethodInfo(Variant::Type::BOOL, "func_with_parameter", PropertyInfo(Variant::STRING_NAME, "param_name", PROPERTY_HINT_NONE, "StringName", PROPERTY_USAGE_NONE)), {"param_name"});
changed the title [-]add_virtual_method with method args crashes when loading editor[/-][+]add_virtual_method with parameter crashes engine when loading editor[/+]on Sep 12, 2024
It'd probably be good to add a check like you show above, but you shouldn't be directly calling ClassDB::add_virtual_method() anyway.
Instead, use the GDVIRTUAL*() and GDVIRTUAL_BIND() macros. They'll take care of all the necessary setup. You can see an example of them in the test code in test/src/example.h and test/src/example.cpp.
Activity
[-]add_virtual_method with method args crashes when loading editor[/-][+]add_virtual_method with parameter crashes engine when loading editor[/+]dsnopek commentedon Sep 12, 2024
Thanks!
It'd probably be good to add a check like you show above, but you shouldn't be directly calling
ClassDB::add_virtual_method()anyway.Instead, use the
GDVIRTUAL*()andGDVIRTUAL_BIND()macros. They'll take care of all the necessary setup. You can see an example of them in the test code intest/src/example.handtest/src/example.cpp.