mirror of
https://github.com/godotengine/godot.git
synced 2026-03-03 20:55:48 +00:00
Prevent cache corruption when saving resources in the editor
This commit is contained in:
@@ -1293,6 +1293,12 @@ void EditorNode::edit_resource(const Ref<Resource> &p_resource) {
|
||||
|
||||
void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const String &p_path) {
|
||||
editor_data.apply_changes_in_editors();
|
||||
|
||||
if (saving_resources_in_path.has(p_resource)) {
|
||||
return;
|
||||
}
|
||||
saving_resources_in_path.insert(p_resource);
|
||||
|
||||
int flg = 0;
|
||||
if (EDITOR_GET("filesystem/on_save/compress_binary_resources")) {
|
||||
flg |= ResourceSaver::FLAG_COMPRESS;
|
||||
@@ -1307,10 +1313,16 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
|
||||
} else {
|
||||
show_accept(TTR("Error saving resource!"), TTR("OK"));
|
||||
}
|
||||
|
||||
saving_resources_in_path.erase(p_resource);
|
||||
return;
|
||||
}
|
||||
|
||||
((Resource *)p_resource.ptr())->set_path(path);
|
||||
saving_resources_in_path.erase(p_resource);
|
||||
|
||||
_resource_saved(p_resource, path);
|
||||
|
||||
emit_signal(SNAME("resource_saved"), p_resource);
|
||||
editor_data.notify_resource_saved(p_resource);
|
||||
}
|
||||
@@ -6511,6 +6523,11 @@ void EditorNode::_renderer_selected(int p_which) {
|
||||
}
|
||||
|
||||
void EditorNode::_resource_saved(Ref<Resource> p_resource, const String &p_path) {
|
||||
if (singleton->saving_resources_in_path.has(p_resource)) {
|
||||
// This is going to be handled by save_resource_in_path when the time is right.
|
||||
return;
|
||||
}
|
||||
|
||||
if (EditorFileSystem::get_singleton()) {
|
||||
EditorFileSystem::get_singleton()->update_file(p_path);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user