Skip to content

Commit 639c41d

Browse files
committed
Merge pull request #107850 from beicause/Fix-Resource-doesn't-update-when-overwritten-in-editor
Fix Resource doesn't update when overwritten in editor
2 parents ee5859b + 0c74c09 commit 639c41d

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

editor/editor_node.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1585,7 +1585,13 @@ void EditorNode::save_resource_in_path(const Ref<Resource> &p_resource, const St
15851585
return;
15861586
}
15871587

1588-
((Resource *)p_resource.ptr())->set_path(path);
1588+
Ref<Resource> prev_resource = ResourceCache::get_ref(p_path);
1589+
if (prev_resource.is_null() || prev_resource != p_resource) {
1590+
p_resource->set_path(path, true);
1591+
}
1592+
if (prev_resource.is_valid() && prev_resource != p_resource) {
1593+
replace_resources_in_scenes({ prev_resource }, { p_resource });
1594+
}
15891595
saving_resources_in_path.erase(p_resource);
15901596

15911597
_resource_saved(p_resource, path);

editor/gui/editor_quick_open_dialog.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -525,15 +525,14 @@ void QuickOpenResultContainer::_use_default_candidates() {
525525
if (history) {
526526
candidates.append_array(*history);
527527
}
528-
int count = candidates.size();
529528
candidates.resize(MIN(max_total_results, filepaths.size()));
529+
int count = candidates.size();
530+
int i = 0;
530531
for (const String &filepath : filepaths) {
531-
if (count >= max_total_results) {
532+
if (i >= count) {
532533
break;
533534
}
534-
if (!history || !history_set.has(filepath)) {
535-
_setup_candidate(candidates.write[count++], filepath);
536-
}
535+
_setup_candidate(candidates.write[i++], filepath);
537536
}
538537
}
539538

0 commit comments

Comments
 (0)