mirror of
https://github.com/godotengine/godot
synced 2024-09-05 21:50:24 +00:00
Fix update_files from PR #92893
This commit is contained in:
parent
5241d30bfa
commit
9f8a918ade
|
@ -1725,7 +1725,7 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {
|
|||
|
||||
if (!_find_file(file, &fs, cpos)) {
|
||||
if (!fs) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1748,77 +1748,72 @@ void EditorFileSystem::update_files(const Vector<String> &p_script_paths) {
|
|||
memdelete(fs->files[cpos]);
|
||||
fs->files.remove_at(cpos);
|
||||
}
|
||||
|
||||
_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);
|
||||
|
||||
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;
|
||||
}
|
||||
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);
|
||||
|
||||
if (idx == fs->files.size()) {
|
||||
fs->files.push_back(fi);
|
||||
} else {
|
||||
fs->files.insert(idx, fi);
|
||||
}
|
||||
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
|
||||
}
|
||||
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);
|
||||
|
||||
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);
|
||||
ResourceUID::ID uid = ResourceLoader::get_resource_uid(file);
|
||||
|
||||
if (uid != ResourceUID::INVALID_ID) {
|
||||
if (ResourceUID::get_singleton()->has_id(uid)) {
|
||||
ResourceUID::get_singleton()->set_id(uid, 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;
|
||||
}
|
||||
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);
|
||||
|
||||
if (idx == fs->files.size()) {
|
||||
fs->files.push_back(fi);
|
||||
} else {
|
||||
fs->files.insert(idx, fi);
|
||||
}
|
||||
cpos = idx;
|
||||
} else {
|
||||
ResourceUID::get_singleton()->add_id(uid, file);
|
||||
//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
|
||||
}
|
||||
|
||||
ResourceUID::get_singleton()->update_cache();
|
||||
}
|
||||
// Update preview
|
||||
EditorResourcePreview::get_singleton()->check_for_invalidation(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 (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 (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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue