How to connect to a function that takes one int parameter in GDNative

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By logicor

I have a function:

Test::setInt(int value) {}

I have registered the method and tried to connect it with:

godot::Array params;
params[0] = 1;
node->connect("pressed", owner, "setInt", params);

And I got a crash when loading the project with godot:

ERROR: Vector<class Variant>::operator []: FATAL: Index p_index=0 out of size (size()=0)
   At: d:\projects\project_aero\godot\core\vector.h:138
CrashHandlerException: Program crashed
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[0] Vector<Variant>::operator[] (d:\projects\project_aero\godot\core\vector.h:138)
[1] Array::operator[] (d:\projects\project_aero\godot\core\array.cpp:76)
[2] godot_array_operator_index (d:\projects\project_aero\godot\modules\gdnative\gdnative\array.cpp:157)
[3] godot::Array::operator[]
[4] saturn::TimeFlowControl::_ready (d:\projects\project_aero\project.gdnative\gdnative\timeflowcontrol.cpp:26)
[5] godot::_WrappedMethod<saturn::TimeFlowControl,void>::apply<> (d:\projects\project_aero\godot-cpp\include\core\godot.hpp:210)
[6] godot::__wrapped_method<saturn::TimeFlowControl,void> (d:\projects\project_aero\godot-cpp\include\core\godot.hpp:228)
[7] NativeScriptInstance::_ml_call_reversed (d:\projects\project_aero\godot\modules\gdnative\nativescript\nativescript.cpp:461)
[8] NativeScriptInstance::call_multilevel_reversed (d:\projects\project_aero\godot\modules\gdnative\nativescript\nativescript.cpp:765)
[9] Node::_notification (d:\projects\project_aero\godot\scene\main\node.cpp:141)
[10] Node::_notificationv (d:\projects\project_aero\godot\scene\main\node.h:46)
[11] CanvasItem::_notificationv (d:\projects\project_aero\godot\scene\2d\canvas_item.h:138)
[12] Control::_notificationv (d:\projects\project_aero\godot\scene\gui\control.h:51)
[13] Container::_notificationv (d:\projects\project_aero\godot\scene\gui\container.h:38)
[14] Object::notification (d:\projects\project_aero\godot\core\object.cpp:926)
[15] Node::_propagate_ready (d:\projects\project_aero\godot\scene\main\node.cpp:184)
[16] Node::_propagate_ready (d:\projects\project_aero\godot\scene\main\node.cpp:178)
[17] Node::_propagate_ready (d:\projects\project_aero\godot\scene\main\node.cpp:178)
[18] Node::_set_tree (d:\projects\project_aero\godot\scene\main\node.cpp:2675)
[19] Node::_add_child_nocheck (d:\projects\project_aero\godot\scene\main\node.cpp:1315)
[20] Node::add_child (d:\projects\project_aero\godot\scene\main\node.cpp:1346)
[21] MethodBind2<Node,Node * __ptr64,bool>::ptrcall (d:\projects\project_aero\godot\core\method_bind.gen.inc:1527)
[22] godot_method_bind_ptrcall (d:\projects\project_aero\godot\modules\gdnative\gdnative\gdnative.cpp:70)
[23] godot::___godot_icall_void_Object_bool
[24] godot::Node::add_child
[25] saturn::RootContainer::_process (d:\projects\project_aero\project.gdnative\gdnative\rootcontainer.cpp:60)
[26] godot::_WrappedMethod<saturn::RootContainer,void,float>::apply<0> (d:\projects\project_aero\godot-cpp\include\core\godot.hpp:210)
[27] godot::__wrapped_method<saturn::RootContainer,void,float> (d:\projects\project_aero\godot-cpp\include\core\godot.hpp:228)
[28] NativeScriptInstance::call_multilevel (d:\projects\project_aero\godot\modules\gdnative\nativescript\nativescript.cpp:748)
[29] Node::_notification (d:\projects\project_aero\godot\scene\main\node.cpp:55)
[30] Node::_notificationv (d:\projects\project_aero\godot\scene\main\node.h:46)
[31] CanvasItem::_notificationv (d:\projects\project_aero\godot\scene\2d\canvas_item.h:138)
[32] Control::_notificationv (d:\projects\project_aero\godot\scene\gui\control.h:51)
[33] Container::_notificationv (d:\projects\project_aero\godot\scene\gui\container.h:38)
[34] Object::notification (d:\projects\project_aero\godot\core\object.cpp:926)
[35] SceneTree::_notify_group_pause (d:\projects\project_aero\godot\scene\main\scene_tree.cpp:938)
[36] SceneTree::idle (d:\projects\project_aero\godot\scene\main\scene_tree.cpp:497)
[37] Main::iteration (d:\projects\project_aero\godot\main\main.cpp:1812)
[38] OS_Windows::run (d:\projects\project_aero\godot\platform\windows\os_windows.cpp:2368)
[39] widechar_main (d:\projects\project_aero\godot\platform\windows\godot_win.cpp:150)
[40] _main (d:\projects\project_aero\godot\platform\windows\godot_win.cpp:172)
[41] main (d:\projects\project_aero\godot\platform\windows\godot_win.cpp:184)
[42] __scrt_common_main_seh (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253)
[43] BaseThreadInitThunk
-- END OF BACKTRACE --

What is the correct way to do it?

:bust_in_silhouette: Reply From: logicor

Nevermind. Looks like I am using the Array in a wrong way. Changed to push_back() and it now works fine.