mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Fix Global Class names cache not saved with upgrade to 4.4.
Co-authored-by: Hilderin <81109165+Hilderin@users.noreply.github.com>
This commit is contained in:
parent
f418603522
commit
2ba64a57c5
7 changed files with 50 additions and 40 deletions
|
@ -1046,24 +1046,23 @@ void EditorData::script_class_set_name(const String &p_path, const StringName &p
|
||||||
_script_class_file_to_path[p_path] = p_class;
|
_script_class_file_to_path[p_path] = p_class;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorData::script_class_save_icon_paths() {
|
void EditorData::script_class_save_global_classes() {
|
||||||
Array script_classes = ProjectSettings::get_singleton()->get_global_class_list();
|
List<StringName> global_classes;
|
||||||
|
ScriptServer::get_global_class_list(&global_classes);
|
||||||
Dictionary d;
|
Array array_classes;
|
||||||
for (const KeyValue<StringName, String> &E : _script_class_icon_paths) {
|
for (const StringName &class_name : global_classes) {
|
||||||
if (ScriptServer::is_global_class(E.key)) {
|
Dictionary d;
|
||||||
d[E.key] = E.value;
|
String *icon = _script_class_icon_paths.getptr(class_name);
|
||||||
}
|
d["class"] = class_name;
|
||||||
|
d["language"] = ScriptServer::get_global_class_language(class_name);
|
||||||
|
d["path"] = ScriptServer::get_global_class_path(class_name);
|
||||||
|
d["base"] = ScriptServer::get_global_class_base(class_name);
|
||||||
|
d["icon"] = icon ? *icon : String();
|
||||||
|
d["is_abstract"] = ScriptServer::is_global_class_abstract(class_name);
|
||||||
|
d["is_tool"] = ScriptServer::is_global_class_tool(class_name);
|
||||||
|
array_classes.push_back(d);
|
||||||
}
|
}
|
||||||
|
ProjectSettings::get_singleton()->store_global_class_list(array_classes);
|
||||||
for (int i = 0; i < script_classes.size(); i++) {
|
|
||||||
Dictionary d2 = script_classes[i];
|
|
||||||
if (!d2.has("class")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
d2["icon"] = d.get(d2["class"], "");
|
|
||||||
}
|
|
||||||
ProjectSettings::get_singleton()->store_global_class_list(script_classes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorData::script_class_load_icon_paths() {
|
void EditorData::script_class_load_icon_paths() {
|
||||||
|
|
|
@ -251,7 +251,7 @@ public:
|
||||||
String script_class_get_icon_path(const String &p_class, bool *r_valid = nullptr) const;
|
String script_class_get_icon_path(const String &p_class, bool *r_valid = nullptr) const;
|
||||||
void script_class_set_icon_path(const String &p_class, const String &p_icon_path);
|
void script_class_set_icon_path(const String &p_class, const String &p_icon_path);
|
||||||
void script_class_clear_icon_paths() { _script_class_icon_paths.clear(); }
|
void script_class_clear_icon_paths() { _script_class_icon_paths.clear(); }
|
||||||
void script_class_save_icon_paths();
|
void script_class_save_global_classes();
|
||||||
void script_class_load_icon_paths();
|
void script_class_load_icon_paths();
|
||||||
|
|
||||||
Ref<Texture2D> extension_class_get_icon(const String &p_class) const;
|
Ref<Texture2D> extension_class_get_icon(const String &p_class) const;
|
||||||
|
|
|
@ -319,7 +319,12 @@ void EditorFileSystem::_first_scan_filesystem() {
|
||||||
_first_scan_process_scripts(first_scan_root_dir, gdextension_extensions, existing_class_names, extensions);
|
_first_scan_process_scripts(first_scan_root_dir, gdextension_extensions, existing_class_names, extensions);
|
||||||
|
|
||||||
// Removing invalid global class to prevent having invalid paths in ScriptServer.
|
// Removing invalid global class to prevent having invalid paths in ScriptServer.
|
||||||
_remove_invalid_global_class_names(existing_class_names);
|
bool save_scripts = _remove_invalid_global_class_names(existing_class_names);
|
||||||
|
|
||||||
|
// If a global class is found or removed, we sync global_script_class_cache.cfg with the ScriptServer
|
||||||
|
if (!existing_class_names.is_empty() || save_scripts) {
|
||||||
|
EditorNode::get_editor_data().script_class_save_global_classes();
|
||||||
|
}
|
||||||
|
|
||||||
// Processing extensions to add new extensions or remove invalid ones.
|
// Processing extensions to add new extensions or remove invalid ones.
|
||||||
// Important to do it in the first scan so custom types, new class names, custom importers, etc...
|
// Important to do it in the first scan so custom types, new class names, custom importers, etc...
|
||||||
|
@ -1618,7 +1623,7 @@ void EditorFileSystem::_thread_func_sources(void *_userdata) {
|
||||||
efs->scanning_changes_done.set();
|
efs->scanning_changes_done.set();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorFileSystem::_remove_invalid_global_class_names(const HashSet<String> &p_existing_class_names) {
|
bool EditorFileSystem::_remove_invalid_global_class_names(const HashSet<String> &p_existing_class_names) {
|
||||||
List<StringName> global_classes;
|
List<StringName> global_classes;
|
||||||
bool must_save = false;
|
bool must_save = false;
|
||||||
ScriptServer::get_global_class_list(&global_classes);
|
ScriptServer::get_global_class_list(&global_classes);
|
||||||
|
@ -1628,9 +1633,7 @@ void EditorFileSystem::_remove_invalid_global_class_names(const HashSet<String>
|
||||||
must_save = true;
|
must_save = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (must_save) {
|
return must_save;
|
||||||
ScriptServer::save_global_classes();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String EditorFileSystem::_get_file_by_class_name(EditorFileSystemDirectory *p_dir, const String &p_class_name, EditorFileSystemDirectory::FileInfo *&r_file_info) {
|
String EditorFileSystem::_get_file_by_class_name(EditorFileSystemDirectory *p_dir, const String &p_class_name, EditorFileSystemDirectory::FileInfo *&r_file_info) {
|
||||||
|
@ -2043,6 +2046,7 @@ EditorFileSystem::ScriptClassInfo EditorFileSystem::_get_global_script_class(con
|
||||||
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
|
for (int i = 0; i < ScriptServer::get_language_count(); i++) {
|
||||||
if (ScriptServer::get_language(i)->handles_global_class_type(p_type)) {
|
if (ScriptServer::get_language(i)->handles_global_class_type(p_type)) {
|
||||||
info.name = ScriptServer::get_language(i)->get_global_class_name(p_path, &info.extends, &info.icon_path, &info.is_abstract, &info.is_tool);
|
info.name = ScriptServer::get_language(i)->get_global_class_name(p_path, &info.extends, &info.icon_path, &info.is_abstract, &info.is_tool);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return info;
|
return info;
|
||||||
|
@ -2130,8 +2134,7 @@ void EditorFileSystem::_update_script_classes() {
|
||||||
update_script_paths.clear();
|
update_script_paths.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptServer::save_global_classes();
|
EditorNode::get_editor_data().script_class_save_global_classes();
|
||||||
EditorNode::get_editor_data().script_class_save_icon_paths();
|
|
||||||
|
|
||||||
emit_signal("script_classes_updated");
|
emit_signal("script_classes_updated");
|
||||||
|
|
||||||
|
|
|
@ -374,7 +374,7 @@ class EditorFileSystem : public Node {
|
||||||
|
|
||||||
void _update_file_icon_path(EditorFileSystemDirectory::FileInfo *file_info);
|
void _update_file_icon_path(EditorFileSystemDirectory::FileInfo *file_info);
|
||||||
void _update_files_icon_path(EditorFileSystemDirectory *edp = nullptr);
|
void _update_files_icon_path(EditorFileSystemDirectory *edp = nullptr);
|
||||||
void _remove_invalid_global_class_names(const HashSet<String> &p_existing_class_names);
|
bool _remove_invalid_global_class_names(const HashSet<String> &p_existing_class_names);
|
||||||
String _get_file_by_class_name(EditorFileSystemDirectory *p_dir, const String &p_class_name, EditorFileSystemDirectory::FileInfo *&r_file_info);
|
String _get_file_by_class_name(EditorFileSystemDirectory *p_dir, const String &p_class_name, EditorFileSystemDirectory::FileInfo *&r_file_info);
|
||||||
|
|
||||||
void _register_global_class_script(const String &p_search_path, const String &p_target_path, const ScriptClassInfoUpdate &p_script_update);
|
void _register_global_class_script(const String &p_search_path, const String &p_target_path, const ScriptClassInfoUpdate &p_script_update);
|
||||||
|
|
|
@ -649,17 +649,11 @@ void EditorNode::_notification(int p_what) {
|
||||||
|
|
||||||
OS::get_singleton()->benchmark_begin_measure("Editor", "First Scan");
|
OS::get_singleton()->benchmark_begin_measure("Editor", "First Scan");
|
||||||
|
|
||||||
if (run_surface_upgrade_tool) {
|
if (run_surface_upgrade_tool || run_uid_upgrade_tool) {
|
||||||
run_surface_upgrade_tool = false;
|
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &EditorNode::_execute_upgrades), CONNECT_ONE_SHOT);
|
||||||
SurfaceUpgradeTool::get_singleton()->connect("upgrade_finished", callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::scan), CONNECT_ONE_SHOT);
|
|
||||||
SurfaceUpgradeTool::get_singleton()->finish_upgrade();
|
|
||||||
} else if (run_uid_upgrade_tool) {
|
|
||||||
run_uid_upgrade_tool = false;
|
|
||||||
UIDUpgradeTool::get_singleton()->connect("upgrade_finished", callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::scan), CONNECT_ONE_SHOT);
|
|
||||||
UIDUpgradeTool::get_singleton()->finish_upgrade();
|
|
||||||
} else {
|
|
||||||
EditorFileSystem::get_singleton()->scan();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EditorFileSystem::get_singleton()->scan();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
|
@ -901,6 +895,20 @@ void EditorNode::_update_update_spinner() {
|
||||||
OS::get_singleton()->set_low_processor_usage_mode(!update_continuously);
|
OS::get_singleton()->set_low_processor_usage_mode(!update_continuously);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EditorNode::_execute_upgrades() {
|
||||||
|
if (run_surface_upgrade_tool) {
|
||||||
|
run_surface_upgrade_tool = false;
|
||||||
|
// Execute another scan to reimport the modified files.
|
||||||
|
SurfaceUpgradeTool::get_singleton()->connect("upgrade_finished", callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::scan), CONNECT_ONE_SHOT);
|
||||||
|
SurfaceUpgradeTool::get_singleton()->finish_upgrade();
|
||||||
|
} else if (run_uid_upgrade_tool) {
|
||||||
|
run_uid_upgrade_tool = false;
|
||||||
|
// Execute another scan to reimport the modified files.
|
||||||
|
UIDUpgradeTool::get_singleton()->connect("upgrade_finished", callable_mp(EditorFileSystem::get_singleton(), &EditorFileSystem::scan), CONNECT_ONE_SHOT);
|
||||||
|
UIDUpgradeTool::get_singleton()->finish_upgrade();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EditorNode::init_plugins() {
|
void EditorNode::init_plugins() {
|
||||||
_initializing_plugins = true;
|
_initializing_plugins = true;
|
||||||
Vector<String> addons;
|
Vector<String> addons;
|
||||||
|
|
|
@ -675,6 +675,8 @@ private:
|
||||||
void _progress_dialog_visibility_changed();
|
void _progress_dialog_visibility_changed();
|
||||||
void _load_error_dialog_visibility_changed();
|
void _load_error_dialog_visibility_changed();
|
||||||
|
|
||||||
|
void _execute_upgrades();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class FileSystemDock;
|
friend class FileSystemDock;
|
||||||
|
|
||||||
|
|
|
@ -1573,8 +1573,7 @@ void FileSystemDock::_update_resource_paths_after_move(const HashMap<String, Str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptServer::save_global_classes();
|
EditorNode::get_editor_data().script_class_save_global_classes();
|
||||||
EditorNode::get_editor_data().script_class_save_icon_paths();
|
|
||||||
EditorFileSystem::get_singleton()->emit_signal(SNAME("script_classes_updated"));
|
EditorFileSystem::get_singleton()->emit_signal(SNAME("script_classes_updated"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1708,8 +1707,7 @@ void FileSystemDock::_resource_removed(const Ref<Resource> &p_resource) {
|
||||||
const Ref<Script> &scr = p_resource;
|
const Ref<Script> &scr = p_resource;
|
||||||
if (scr.is_valid()) {
|
if (scr.is_valid()) {
|
||||||
ScriptServer::remove_global_class_by_path(scr->get_path());
|
ScriptServer::remove_global_class_by_path(scr->get_path());
|
||||||
ScriptServer::save_global_classes();
|
EditorNode::get_editor_data().script_class_save_global_classes();
|
||||||
EditorNode::get_editor_data().script_class_save_icon_paths();
|
|
||||||
EditorFileSystem::get_singleton()->emit_signal(SNAME("script_classes_updated"));
|
EditorFileSystem::get_singleton()->emit_signal(SNAME("script_classes_updated"));
|
||||||
}
|
}
|
||||||
emit_signal(SNAME("resource_removed"), p_resource);
|
emit_signal(SNAME("resource_removed"), p_resource);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue