From ee74c7808b99db69fd34fbff8d86ef232f349a1e Mon Sep 17 00:00:00 2001 From: Zaven Muradyan Date: Sat, 13 Oct 2018 22:05:53 -0700 Subject: Update autoload references when moving files. Prior to this, file references in autoload were not updated when a script was moved or renamed. This adds extra logic to update the autoload references when updating project settings. Fixes #22995. --- editor/filesystem_dock.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'editor/filesystem_dock.cpp') diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 4d386c1af6..5d155c3014 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -1172,6 +1172,23 @@ void FileSystemDock::_update_project_settings_after_move(const Map property_list; + ProjectSettings::get_singleton()->get_property_list(&property_list); + for (const List::Element *E = property_list.front(); E; E = E->next()) { + if (E->get().name.begins_with("autoload/")) { + // If the autoload resource paths has a leading "*", it indicates that it is a Singleton, + // so we have to handle both cases when updating. + String autoload = GLOBAL_GET(E->get().name); + String autoload_singleton = autoload.substr(1, autoload.length()); + if (p_renames.has(autoload)) { + ProjectSettings::get_singleton()->set_setting(E->get().name, p_renames[autoload]); + } else if (autoload.begins_with("*") && p_renames.has(autoload_singleton)) { + ProjectSettings::get_singleton()->set_setting(E->get().name, "*" + p_renames[autoload_singleton]); + } + } + } ProjectSettings::get_singleton()->save(); } -- cgit v1.2.3