diff options
author | George L. Albany <Megacake1234@gmail.com> | 2024-11-27 21:15:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-27 21:15:49 +0000 |
commit | 85d87116e184e7923b8d6804cab2681b61c62d83 (patch) | |
tree | 55ec5bfa061a5c27272b831e697b78ed1b756a70 /editor/editor_resource_preview.cpp | |
parent | b06d20bf39d15ec736d08d4e4fcb32e0c3c1ce1e (diff) | |
parent | 721f53fde47c2727d99e3ecccdb789a67df36de0 (diff) | |
download | redot-engine-85d87116e184e7923b8d6804cab2681b61c62d83.tar.gz |
Merge commit godotengine/godot@f128f38
Diffstat (limited to 'editor/editor_resource_preview.cpp')
-rw-r--r-- | editor/editor_resource_preview.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index ba79f28729..41b872bf5d 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -149,6 +149,10 @@ void EditorResourcePreview::_preview_ready(const String &p_path, int p_hash, con if (!p_path.begins_with("ID:")) { modified_time = FileAccess::get_modified_time(p_path); + String import_path = p_path + ".import"; + if (FileAccess::exists(import_path)) { + modified_time = MAX(modified_time, FileAccess::get_modified_time(import_path)); + } } Item item; @@ -239,7 +243,14 @@ void EditorResourcePreview::_generate_preview(Ref<ImageTexture> &r_texture, Ref< } Ref<FileAccess> f = FileAccess::open(cache_base + ".txt", FileAccess::WRITE); ERR_FAIL_COND_MSG(f.is_null(), "Cannot create file '" + cache_base + ".txt'. Check user write permissions."); - _write_preview_cache(f, thumbnail_size, has_small_texture, FileAccess::get_modified_time(p_item.path), FileAccess::get_md5(p_item.path), p_metadata); + + uint64_t modtime = FileAccess::get_modified_time(p_item.path); + String import_path = p_item.path + ".import"; + if (FileAccess::exists(import_path)) { + modtime = MAX(modtime, FileAccess::get_modified_time(import_path)); + } + + _write_preview_cache(f, thumbnail_size, has_small_texture, modtime, FileAccess::get_md5(p_item.path), p_metadata); } } @@ -300,6 +311,11 @@ void EditorResourcePreview::_iterate() { _generate_preview(texture, small_texture, item, cache_base, preview_metadata); } else { uint64_t modtime = FileAccess::get_modified_time(item.path); + String import_path = item.path + ".import"; + if (FileAccess::exists(import_path)) { + modtime = MAX(modtime, FileAccess::get_modified_time(import_path)); + } + int tsize; bool has_small_texture; uint64_t last_modtime; @@ -515,6 +531,11 @@ void EditorResourcePreview::check_for_invalidation(const String &p_path) { if (cache.has(p_path)) { uint64_t modified_time = FileAccess::get_modified_time(p_path); + String import_path = p_path + ".import"; + if (FileAccess::exists(import_path)) { + modified_time = MAX(modified_time, FileAccess::get_modified_time(import_path)); + } + if (modified_time != cache[p_path].modified_time) { cache.erase(p_path); call_invalidated = true; |