From 8cdbec0434fd95c303c670985406224c2c6b5232 Mon Sep 17 00:00:00 2001 From: DmitriySalnikov Date: Sun, 26 Nov 2023 09:53:05 +0300 Subject: [PATCH] Update cached singletons when reloading GDScripts --- modules/gdscript/gdscript.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 05c255841774..0103168be367 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -2323,6 +2323,19 @@ void GDScriptLanguage::reload_all_scripts() { } elem = elem->next(); } + +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + // Reload all pointers to existing singletons so that tool scripts can work with the reloaded extensions. + List singletons; + Engine::get_singleton()->get_singletons(&singletons); + for (const Engine::Singleton &E : singletons) { + if (globals.has(E.name)) { + _add_global(E.name, E.ptr); + } + } + } +#endif } //as scripts are going to be reloaded, must proceed without locking here