diff options
Diffstat (limited to 'core/resource.cpp')
-rw-r--r-- | core/resource.cpp | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/core/resource.cpp b/core/resource.cpp index f8948e9a59..0d8a223b78 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -39,7 +39,6 @@ #include <stdio.h> void Resource::emit_changed() { - emit_signal(CoreStringNames::get_singleton()->changed); } @@ -47,12 +46,10 @@ void Resource::_resource_path_changed() { } void Resource::set_path(const String &p_path, bool p_take_over) { - if (path_cache == p_path) return; if (path_cache != "") { - ResourceCache::lock->write_lock(); ResourceCache::resources.erase(path_cache); ResourceCache::lock->write_unlock(); @@ -66,7 +63,6 @@ void Resource::set_path(const String &p_path, bool p_take_over) { if (has_path) { if (p_take_over) { - ResourceCache::lock->write_lock(); Resource **res = ResourceCache::resources.getptr(p_path); if (res) { @@ -84,7 +80,6 @@ void Resource::set_path(const String &p_path, bool p_take_over) { path_cache = p_path; if (path_cache != "") { - ResourceCache::lock->write_lock(); ResourceCache::resources[path_cache] = this; ResourceCache::lock->write_unlock(); @@ -95,37 +90,30 @@ void Resource::set_path(const String &p_path, bool p_take_over) { } String Resource::get_path() const { - return path_cache; } void Resource::set_subindex(int p_sub_index) { - subindex = p_sub_index; } int Resource::get_subindex() const { - return subindex; } void Resource::set_name(const String &p_name) { - name = p_name; _change_notify("resource_name"); } String Resource::get_name() const { - return name; } bool Resource::editor_can_reload_from_file() { - return true; //by default yes } void Resource::reload_from_file() { - String path = get_path(); if (!path.is_resource_file()) return; @@ -139,7 +127,6 @@ void Resource::reload_from_file() { s->get_property_list(&pi); for (List<PropertyInfo>::Element *E = pi.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) continue; if (E->get().name == "resource_path") @@ -150,7 +137,6 @@ void Resource::reload_from_file() { } Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource>> &remap_cache) { - List<PropertyInfo> plist; get_property_list(&plist); @@ -160,20 +146,16 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res r->local_scene = p_for_scene; for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) continue; Variant p = get(E->get().name); if (p.get_type() == Variant::OBJECT) { - RES sr = p; if (sr.is_valid()) { - if (sr->is_local_to_scene()) { if (remap_cache.has(sr)) { p = remap_cache[sr]; } else { - RES dupe = sr->duplicate_for_local_scene(p_for_scene, remap_cache); p = dupe; remap_cache[sr] = dupe; @@ -191,22 +173,18 @@ Ref<Resource> Resource::duplicate_for_local_scene(Node *p_for_scene, Map<Ref<Res } void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, Ref<Resource>> &remap_cache) { - List<PropertyInfo> plist; get_property_list(&plist); local_scene = p_for_scene; for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) continue; Variant p = get(E->get().name); if (p.get_type() == Variant::OBJECT) { - RES sr = p; if (sr.is_valid()) { - if (sr->is_local_to_scene()) { if (!remap_cache.has(sr)) { sr->configure_for_local_scene(p_for_scene, remap_cache); @@ -219,7 +197,6 @@ void Resource::configure_for_local_scene(Node *p_for_scene, Map<Ref<Resource>, R } Ref<Resource> Resource::duplicate(bool p_subresources) const { - List<PropertyInfo> plist; get_property_list(&plist); @@ -227,7 +204,6 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const { ERR_FAIL_COND_V(!r, Ref<Resource>()); for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) continue; Variant p = get(E->get().name); @@ -235,13 +211,11 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const { if ((p.get_type() == Variant::DICTIONARY || p.get_type() == Variant::ARRAY)) { r->set(E->get().name, p.duplicate(p_subresources)); } else if (p.get_type() == Variant::OBJECT && (p_subresources || (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) { - RES sr = p; if (sr.is_valid()) { r->set(E->get().name, sr->duplicate(p_subresources)); } } else { - r->set(E->get().name, p); } } @@ -250,34 +224,27 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const { } void Resource::_set_path(const String &p_path) { - set_path(p_path, false); } void Resource::_take_over_path(const String &p_path) { - set_path(p_path, true); } RID Resource::get_rid() const { - return RID(); } void Resource::register_owner(Object *p_owner) { - owners.insert(p_owner->get_instance_id()); } void Resource::unregister_owner(Object *p_owner) { - owners.erase(p_owner->get_instance_id()); } void Resource::notify_change_to_owners() { - for (Set<ObjectID>::Element *E = owners.front(); E; E = E->next()) { - Object *obj = ObjectDB::get_instance(E->get()); ERR_CONTINUE_MSG(!obj, "Object was deleted, while still owning a resource."); //wtf //TODO store string @@ -288,14 +255,12 @@ void Resource::notify_change_to_owners() { #ifdef TOOLS_ENABLED uint32_t Resource::hash_edited_version() const { - uint32_t hash = hash_djb2_one_32(get_edited_version()); List<PropertyInfo> plist; get_property_list(&plist); for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_STORAGE && E->get().type == Variant::OBJECT && E->get().hint == PROPERTY_HINT_RESOURCE_TYPE) { RES res = get(E->get().name); if (res.is_valid()) { @@ -310,17 +275,14 @@ uint32_t Resource::hash_edited_version() const { #endif void Resource::set_local_to_scene(bool p_enable) { - local_to_scene = p_enable; } bool Resource::is_local_to_scene() const { - return local_to_scene; } Node *Resource::get_local_scene() const { - if (local_scene) return local_scene; @@ -332,7 +294,6 @@ Node *Resource::get_local_scene() const { } void Resource::setup_local_to_scene() { - if (get_script_instance()) get_script_instance()->call("_setup_local_to_scene"); } @@ -340,7 +301,6 @@ void Resource::setup_local_to_scene() { Node *(*Resource::_get_local_scene_func)() = nullptr; void Resource::set_as_translation_remapped(bool p_remapped) { - if (remapped_list.in_list() == p_remapped) return; @@ -360,7 +320,6 @@ void Resource::set_as_translation_remapped(bool p_remapped) { } bool Resource::is_translation_remapped() const { - return remapped_list.in_list(); } @@ -406,7 +365,6 @@ int Resource::get_id_for_path(const String &p_path) const { #endif void Resource::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_path", "path"), &Resource::_set_path); ClassDB::bind_method(D_METHOD("take_over_path", "path"), &Resource::_take_over_path); ClassDB::bind_method(D_METHOD("get_path"), &Resource::get_path); @@ -432,7 +390,6 @@ Resource::Resource() : remapped_list(this) {} Resource::~Resource() { - if (path_cache != "") { ResourceCache::lock->write_lock(); ResourceCache::resources.erase(path_cache); @@ -454,7 +411,6 @@ RWLock *ResourceCache::path_cache_lock = nullptr; #endif void ResourceCache::setup() { - lock = RWLock::create(); #ifdef TOOLS_ENABLED path_cache_lock = RWLock::create(); @@ -473,7 +429,6 @@ void ResourceCache::clear() { } void ResourceCache::reload_externals() { - /* const String *K=nullptr; while ((K=resources.next(K))) { @@ -483,7 +438,6 @@ void ResourceCache::reload_externals() { } bool ResourceCache::has(const String &p_path) { - lock->read_lock(); bool b = resources.has(p_path); lock->read_unlock(); @@ -491,7 +445,6 @@ bool ResourceCache::has(const String &p_path) { return b; } Resource *ResourceCache::get(const String &p_path) { - lock->read_lock(); Resource **res = resources.getptr(p_path); @@ -506,11 +459,9 @@ Resource *ResourceCache::get(const String &p_path) { } void ResourceCache::get_cached_resources(List<Ref<Resource>> *p_resources) { - lock->read_lock(); const String *K = nullptr; while ((K = resources.next(K))) { - Resource *r = resources[*K]; p_resources->push_back(Ref<Resource>(r)); } @@ -518,7 +469,6 @@ void ResourceCache::get_cached_resources(List<Ref<Resource>> *p_resources) { } int ResourceCache::get_cached_resource_count() { - lock->read_lock(); int rc = resources.size(); lock->read_unlock(); @@ -540,7 +490,6 @@ void ResourceCache::dump(const char *p_file, bool p_short) { const String *K = nullptr; while ((K = resources.next(K))) { - Resource *r = resources[*K]; if (!type_count.has(r->get_class())) { @@ -556,7 +505,6 @@ void ResourceCache::dump(const char *p_file, bool p_short) { } for (Map<String, int>::Element *E = type_count.front(); E; E = E->next()) { - if (f) f->store_line(E->key() + " count: " + itos(E->get())); } |