Skip to content

Commit

Permalink
Fix update_files from PR godotengine#92893
Browse files Browse the repository at this point in the history
  • Loading branch information
Hilderin authored and 2nafish117 committed Aug 5, 2024
1 parent 8fc65a4 commit 6070eaf
Showing 1 changed file with 55 additions and 60 deletions.
115 changes: 55 additions & 60 deletions editor/editor_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1725,7 +1725,7 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {

if (!_find_file(file, &fs, cpos)) {
if (!fs) {
return;
continue;
}
}

Expand All @@ -1748,77 +1748,72 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {
memdelete(fs->files[cpos]);
fs->files.remove_at(cpos);
}
} else {
String type = ResourceLoader::get_resource_type(file);
if (type.is_empty() && textfile_extensions.has(file.get_extension())) {
type = "TextFile";
}
String script_class = ResourceLoader::get_resource_script_class(file);

_update_pending_script_classes();
_update_pending_scene_groups();
call_deferred(SNAME("emit_signal"), "filesystem_changed"); //update later
return;
}

String type = ResourceLoader::get_resource_type(file);
if (type.is_empty() && textfile_extensions.has(file.get_extension())) {
type = "TextFile";
}
String script_class = ResourceLoader::get_resource_script_class(file);

ResourceUID::ID uid = ResourceLoader::get_resource_uid(file);
ResourceUID::ID uid = ResourceLoader::get_resource_uid(file);

if (cpos == -1) {
// The file did not exist, it was added.
int idx = 0;
String file_name = file.get_file();
if (cpos == -1) {
// The file did not exist, it was added.
int idx = 0;
String file_name = file.get_file();

for (int i = 0; i < fs->files.size(); i++) {
if (file.filenocasecmp_to(fs->files[i]->file) < 0) {
break;
for (int i = 0; i < fs->files.size(); i++) {
if (file.filenocasecmp_to(fs->files[i]->file) < 0) {
break;
}
idx++;
}
idx++;
}

EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo);
fi->file = file_name;
fi->import_modified_time = 0;
fi->import_valid = type == "TextFile" ? true : ResourceLoader::is_import_valid(file);
EditorFileSystemDirectory::FileInfo *fi = memnew(EditorFileSystemDirectory::FileInfo);
fi->file = file_name;
fi->import_modified_time = 0;
fi->import_valid = type == "TextFile" ? true : ResourceLoader::is_import_valid(file);

if (idx == fs->files.size()) {
fs->files.push_back(fi);
if (idx == fs->files.size()) {
fs->files.push_back(fi);
} else {
fs->files.insert(idx, fi);
}
cpos = idx;
} else {
fs->files.insert(idx, fi);
//the file exists and it was updated, and was not added in this step.
//this means we must force upon next restart to scan it again, to get proper type and dependencies
late_update_files.insert(file);
_save_late_updated_files(); //files need to be updated in the re-scan
}
cpos = idx;
} else {
//the file exists and it was updated, and was not added in this step.
//this means we must force upon next restart to scan it again, to get proper type and dependencies
late_update_files.insert(file);
_save_late_updated_files(); //files need to be updated in the re-scan
}

fs->files[cpos]->type = type;
fs->files[cpos]->resource_script_class = script_class;
fs->files[cpos]->uid = uid;
fs->files[cpos]->script_class_name = _get_global_script_class(type, file, &fs->files[cpos]->script_class_extends, &fs->files[cpos]->script_class_icon_path);
fs->files[cpos]->import_group_file = ResourceLoader::get_import_group_file(file);
fs->files[cpos]->modified_time = FileAccess::get_modified_time(file);
fs->files[cpos]->deps = _get_dependencies(file);
fs->files[cpos]->import_valid = type == "TextFile" ? true : ResourceLoader::is_import_valid(file);
fs->files[cpos]->type = type;
fs->files[cpos]->resource_script_class = script_class;
fs->files[cpos]->uid = uid;
fs->files[cpos]->script_class_name = _get_global_script_class(type, file, &fs->files[cpos]->script_class_extends, &fs->files[cpos]->script_class_icon_path);
fs->files[cpos]->import_group_file = ResourceLoader::get_import_group_file(file);
fs->files[cpos]->modified_time = FileAccess::get_modified_time(file);
fs->files[cpos]->deps = _get_dependencies(file);
fs->files[cpos]->import_valid = type == "TextFile" ? true : ResourceLoader::is_import_valid(file);

if (uid != ResourceUID::INVALID_ID) {
if (ResourceUID::get_singleton()->has_id(uid)) {
ResourceUID::get_singleton()->set_id(uid, file);
} else {
ResourceUID::get_singleton()->add_id(uid, file);
}

if (uid != ResourceUID::INVALID_ID) {
if (ResourceUID::get_singleton()->has_id(uid)) {
ResourceUID::get_singleton()->set_id(uid, file);
} else {
ResourceUID::get_singleton()->add_id(uid, file);
ResourceUID::get_singleton()->update_cache();
}
// Update preview
EditorResourcePreview::get_singleton()->check_for_invalidation(file);

ResourceUID::get_singleton()->update_cache();
}
// Update preview
EditorResourcePreview::get_singleton()->check_for_invalidation(file);

if (ClassDB::is_parent_class(fs->files[cpos]->type, SNAME("Script"))) {
_queue_update_script_class(file);
}
if (fs->files[cpos]->type == SNAME("PackedScene")) {
_queue_update_scene_groups(file);
if (ClassDB::is_parent_class(fs->files[cpos]->type, SNAME("Script"))) {
_queue_update_script_class(file);
}
if (fs->files[cpos]->type == SNAME("PackedScene")) {
_queue_update_scene_groups(file);
}
}
}

Expand Down

0 comments on commit 6070eaf

Please sign in to comment.