godot
godot copied to clipboard
Fix editor needs restart after adding GDExtensions
Fixes #77478
This PR should prevent the need to restart the editor when a new GDExtension is installed or when starting the editor for the first time without the extension_list.cfg file.
Modifications:
- Added a scan for new or invalid extensions before the first scan.
- Added registering and unregistering for extension classes in GDScript globals so scripts can work without restarting the editor.
- Moved the addition and removal of extensions and the writing of
extension_list.cfgtoGDExtensionManager::ensure_extensions_loadedto facilitate the emission of theextensions_reloadedsignal and to call_reload_all_scriptswhen extensions are added or removed. - Added
ScriptEditor::get_singleton()->reload_scriptsonextensions_reloadedinEditorNodeto revalidate the opened scripts and fix GDScript errors when extensions are added while the editor is running and GDScripts are opened that use classes from the extension.
Known issues:
- When an extension is removed (removing the .gdextension file) and a scene containing nodes from this extension is opened, the editor crashes. This issue was already present. I'm wondering how to fix this, maybe by reloading the scenes when adding or removing extensions? I could be problematic for the user to always reload scene when reloading extensions??
- The editor crashes when using a class from an extension as the base class for an autoload script with
@tool. This issue was already present.
Not tested:
- Extensions with custom resource importers or types.
- Plugin extensions.
- Extension with HotReload.
MRP used to test this (only built for Windows):
It's based on the MRP from #77478 but modified for Godot 4.3 master. test-godot-minimal_repro.zip