MikeSchulze / gdUnit4

A Godot Unit Test Framework. Support for GDScript and C# unit testing
MIT License
565 stars 30 forks source link

GD-506: Revisit the `ScriptEditorContextMenuHandler` added to the root node #506

Closed MikeSchulze closed 3 months ago

MikeSchulze commented 3 months ago

Describe What The ScriptEditorContextMenuHandler is added to the root node and removed at plugin exit and results into problems. Instead, we should add it as child to the GdUnit inspector to be managed by this component instead of duing manually delete at plugin exit via dispose.

Dev hints res://addons/gdUnit4/src/ui/ScriptEditorControls.gd

# Register the given context menu to the current script editor
# Is called when the plugin is activated
# The active script is connected to the ScriptEditorContextMenuHandler
static func register_context_menu(menu: Array[GdUnitContextMenuItem]) -> void:
    Engine.get_main_loop().root.call_deferred("add_child", ScriptEditorContextMenuHandler.new(menu))

# Unregisteres all registerend context menus and gives the ScriptEditorContextMenuHandler> free
# Is called when the plugin is deactivated
static func unregister_context_menu() -> void:
    ScriptEditorContextMenuHandler.dispose()