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
I maintain a module that can also compile as an extension, and it needs to register EditorPlugins. The problem is that in order to work, I have to register all the classes that take part in these plugins:
But I don't intend these classes to be accessible by users... just like a plethora of editor classes in Godot core.
This causes a number of issues:
It pollutes the Add Node dialog with nodes that should never be created by the user.
It pollutes the Editor Help with classes that should not be accessible.
It crashes Godot on startup because in order to get the default values of properties, Editor Help uses ClassDB to make temporary instances of every class, which then involves running the constructor of one of these plugin classes, which can want to access EditorNode or other editor-only singletons that may not exist at that time (this is another serious problem which needs its own issue!).
In cases it doesn't crash, it slows down editor startup, because some editors can be quite heavy in UIs or viewports.
Ideally, there must be a way to register a class for Godot to be able to instantiate an extension, but without exposing it, which means none of these issues would occur in the first place.
- Don't access EditorNode indirectly from EditorPlugin constructors,
see godotengine/godot-cpp#1179
- Don't access RenderingServer directly from any registered constructor,
see godotengine/godot-cpp#1180
- Register a few missing classes
A plethora of hidden issues remain. Terrains crash as soon as they
start generating stuff.
Zylann
changed the title
No way to avoid exposing editor-only classes
There should be a way to register classes without exposing them (usually editor plugin internals)
Jul 19, 2023
It pollutes the Add Node dialog with nodes that should never be created by the user.
It pollutes the Editor Help with classes that should not be accessible.
Both can easily be solved by using the GDREGISTER_INTERNAL_CLASS macro. These classes won't appear in the Add Node dialog window nor in the editor help search window when using F1 or whatever you have bound search/help to.
Godot version
Godot 4.0, 4.1
godot-cpp version
4.1
System information
Windows 10 64 bits NVIDIA GeForce GTX 1060
Issue description
I maintain a module that can also compile as an extension, and it needs to register EditorPlugins. The problem is that in order to work, I have to register all the classes that take part in these plugins:
https://github.com/Zylann/godot_voxel/blob/3f4b0b20cd6e9a093c60a3116decd63710c168e0/register_types.cpp#L342-L386
But I don't intend these classes to be accessible by users... just like a plethora of editor classes in Godot core.
This causes a number of issues:
EditorNode
or other editor-only singletons that may not exist at that time (this is another serious problem which needs its own issue!).Ideally, there must be a way to register a class for Godot to be able to instantiate an extension, but without exposing it, which means none of these issues would occur in the first place.
I assume #970 would fix it.
Example of crash:
https://github.com/Zylann/godot_voxel/blob/3f4b0b20cd6e9a093c60a3116decd63710c168e0/editor/blocky_library/voxel_blocky_library_editor_plugin.cpp#L32
Steps to reproduce
Have an
EditorPlugin
that callsget_editor_interface()->get_base_control()
in its constructor.Minimal reproduction project
N.A
The text was updated successfully, but these errors were encountered: