godot icon indicating copy to clipboard operation
godot copied to clipboard

Fix editor needs restart after adding GDExtensions

Open Hilderin opened this issue 1 year ago • 0 comments

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.cfg to GDExtensionManager::ensure_extensions_loaded to facilitate the emission of the extensions_reloaded signal and to call _reload_all_scripts when extensions are added or removed.
  • Added ScriptEditor::get_singleton()->reload_scripts on extensions_reloaded in EditorNode to 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

Hilderin avatar Jul 05 '24 14:07 Hilderin