Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions core/io/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,26 @@ void Resource::set_path(const String &p_path, bool p_take_over) {
Ref<Resource> existing = ResourceCache::get_ref(p_path);

if (existing.is_valid()) {
if (p_take_over) {
if (existing.ptr() == this) {
} else if (p_take_over) {
existing->path_cache = String();
ResourceCache::resources.erase(p_path);
} else {
ERR_FAIL_MSG(vformat("Another resource is loaded from path '%s' (possible cyclic resource inclusion).", p_path));
if (existing->get_reference_count() <= 1) {
existing->path_cache = String();
ResourceCache::resources.erase(p_path);
} else {
#ifdef TOOLS_ENABLED
if (path_cache.is_empty()) {
existing->path_cache = String();
ResourceCache::resources.erase(p_path);
} else {
ERR_FAIL_MSG(vformat("Another resource is loaded from path '%s' (possible cyclic resource inclusion).", p_path));
}
#else
ERR_FAIL_MSG(vformat("Another resource is loaded from path '%s' (possible cyclic resource inclusion).", p_path));
#endif
}
}
}

Expand Down