Using add_tool_menu_item
in C++ Editor Plugin Fails with "Index is out of bounds" Error
#1549
Labels
bug
This has been identified as a bug
Godot version
v4.2.2.stable.official [15073afe3]
godot-cpp version
4.2.2.stable
System information
Godot v4.2.2.stable - macOS 14.5.0 - Vulkan (Mobile) - integrated Apple M3 Max - Apple M3 Max (16 Threads)
Issue description
I am trying to write a helper tool from a C++ GDExtension.
When I use
add_tool_menu_item
to add an item to the tool menu, the item does appear in the Editor. However, clicking on it doesn't actually perform the associated action; instead, it shows this error:Interestingly, recompiling the GDExtension (and forcing the hot reload behavior) fixes the issue, and the menu item works. However, if you restart the editor, the error occurs again until the GDExtension is hot reloaded.
While the "hot reload" thing is a workaround, it isn't feasible for non-technical team members who don't have the tools or knowledge to recompile the extension (and the whole reason I'm adding a menu item is for those team members!).
One final note, I was able to work around this by using a GDScript editor plugin that calls into my C++ code (and assuming I bind the function so GDScript can call it):
I have only tested this on macOS so far. I tried to debug via the engine source code, but I wasn't able to identify the cause. Two things I did notice:
Steps to reproduce
Project > Tools > Custom Tool Menu Item
and click it.Minimal reproduction project
GodotProject.zip
The text was updated successfully, but these errors were encountered: