Skip to content

Commit

Permalink
Merge pull request #85373 from DmitriySalnikov/update_singletons
Browse files Browse the repository at this point in the history
Fix updating cached singletons when reloading GDScripts
  • Loading branch information
akien-mga committed Dec 4, 2023
2 parents 8580874 + 8cdbec0 commit d75c446
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions modules/gdscript/gdscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,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<Engine::Singleton> 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
Expand Down

0 comments on commit d75c446

Please sign in to comment.