mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Fix external resource IDs being lost for default properties
This commit is contained in:
parent
2d113cc224
commit
d0826b0bfe
3 changed files with 16 additions and 12 deletions
|
@ -672,25 +672,25 @@ void Resource::set_as_translation_remapped(bool p_remapped) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helps keep IDs the same when loading/saving scenes. An empty ID clears the entry, and an empty ID is returned when not found.
|
// Helps keep IDs the same when loading/saving scenes. An empty ID clears the entry, and an empty ID is returned when not found.
|
||||||
void Resource::set_id_for_path(const String &p_path, const String &p_id) {
|
void Resource::set_resource_id_for_path(const String &p_referrer_path, const String &p_resource_path, const String &p_id) {
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
if (p_id.is_empty()) {
|
if (p_id.is_empty()) {
|
||||||
ResourceCache::path_cache_lock.write_lock();
|
ResourceCache::path_cache_lock.write_lock();
|
||||||
ResourceCache::resource_path_cache[p_path].erase(get_path());
|
ResourceCache::resource_path_cache[p_referrer_path].erase(p_resource_path);
|
||||||
ResourceCache::path_cache_lock.write_unlock();
|
ResourceCache::path_cache_lock.write_unlock();
|
||||||
} else {
|
} else {
|
||||||
ResourceCache::path_cache_lock.write_lock();
|
ResourceCache::path_cache_lock.write_lock();
|
||||||
ResourceCache::resource_path_cache[p_path][get_path()] = p_id;
|
ResourceCache::resource_path_cache[p_referrer_path][p_resource_path] = p_id;
|
||||||
ResourceCache::path_cache_lock.write_unlock();
|
ResourceCache::path_cache_lock.write_unlock();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
String Resource::get_id_for_path(const String &p_path) const {
|
String Resource::get_id_for_path(const String &p_referrer_path) const {
|
||||||
#ifdef TOOLS_ENABLED
|
#ifdef TOOLS_ENABLED
|
||||||
ResourceCache::path_cache_lock.read_lock();
|
ResourceCache::path_cache_lock.read_lock();
|
||||||
if (ResourceCache::resource_path_cache[p_path].has(get_path())) {
|
if (ResourceCache::resource_path_cache[p_referrer_path].has(get_path())) {
|
||||||
String result = ResourceCache::resource_path_cache[p_path][get_path()];
|
String result = ResourceCache::resource_path_cache[p_referrer_path][get_path()];
|
||||||
ResourceCache::path_cache_lock.read_unlock();
|
ResourceCache::path_cache_lock.read_unlock();
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -181,8 +181,9 @@ public:
|
||||||
virtual RID get_rid() const; // Some resources may offer conversion to RID.
|
virtual RID get_rid() const; // Some resources may offer conversion to RID.
|
||||||
|
|
||||||
// Helps keep IDs the same when loading/saving scenes. An empty ID clears the entry, and an empty ID is returned when not found.
|
// Helps keep IDs the same when loading/saving scenes. An empty ID clears the entry, and an empty ID is returned when not found.
|
||||||
void set_id_for_path(const String &p_path, const String &p_id);
|
static void set_resource_id_for_path(const String &p_referrer_path, const String &p_resource_path, const String &p_id);
|
||||||
String get_id_for_path(const String &p_path) const;
|
void set_id_for_path(const String &p_referrer_path, const String &p_id) { set_resource_id_for_path(p_referrer_path, get_path(), p_id); }
|
||||||
|
String get_id_for_path(const String &p_referrer_path) const;
|
||||||
|
|
||||||
Resource();
|
Resource();
|
||||||
~Resource();
|
~Resource();
|
||||||
|
|
|
@ -157,10 +157,6 @@ Error ResourceLoaderText::_parse_ext_resource(VariantParser::Stream *p_stream, R
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef TOOLS_ENABLED
|
|
||||||
//remember ID for saving
|
|
||||||
res->set_id_for_path(local_path, id);
|
|
||||||
#endif
|
|
||||||
r_res = res;
|
r_res = res;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -486,6 +482,13 @@ Error ResourceLoaderText::load() {
|
||||||
resource_current++;
|
resource_current++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef TOOLS_ENABLED
|
||||||
|
for (const KeyValue<String, ExtResource> &E : ext_resources) {
|
||||||
|
// Remember ID for saving.
|
||||||
|
Resource::set_resource_id_for_path(local_path, E.value.path, E.key);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//these are the ones that count
|
//these are the ones that count
|
||||||
resources_total -= resource_current;
|
resources_total -= resource_current;
|
||||||
resource_current = 0;
|
resource_current = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue