From 0c74c0978fd3a204297af57471d64cf65ecd8fd6 Mon Sep 17 00:00:00 2001 From: LuoZhihao Date: Sun, 29 Jun 2025 01:08:11 +0800 Subject: [PATCH] Fix Resource doesn't update when overwritten in editor --- editor/editor_node.cpp | 8 +++++++- editor/gui/editor_quick_open_dialog.cpp | 9 ++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index f188d8e74f..c6d9fff010 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1585,7 +1585,13 @@ void EditorNode::save_resource_in_path(const Ref &p_resource, const St return; } - ((Resource *)p_resource.ptr())->set_path(path); + Ref prev_resource = ResourceCache::get_ref(p_path); + if (prev_resource.is_null() || prev_resource != p_resource) { + p_resource->set_path(path, true); + } + if (prev_resource.is_valid() && prev_resource != p_resource) { + replace_resources_in_scenes({ prev_resource }, { p_resource }); + } saving_resources_in_path.erase(p_resource); _resource_saved(p_resource, path); diff --git a/editor/gui/editor_quick_open_dialog.cpp b/editor/gui/editor_quick_open_dialog.cpp index 449c2e7b35..2bc178f8c2 100644 --- a/editor/gui/editor_quick_open_dialog.cpp +++ b/editor/gui/editor_quick_open_dialog.cpp @@ -525,15 +525,14 @@ void QuickOpenResultContainer::_use_default_candidates() { if (history) { candidates.append_array(*history); } - int count = candidates.size(); candidates.resize(MIN(max_total_results, filepaths.size())); + int count = candidates.size(); + int i = 0; for (const String &filepath : filepaths) { - if (count >= max_total_results) { + if (i >= count) { break; } - if (!history || !history_set.has(filepath)) { - _setup_candidate(candidates.write[count++], filepath); - } + _setup_candidate(candidates.write[i++], filepath); } }