summaryrefslogtreecommitdiffstats
path: root/core/io/resource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/io/resource.cpp')
-rw-r--r--core/io/resource.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index 6b8ec8d5f6..07677337b4 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -147,15 +147,28 @@ bool Resource::editor_can_reload_from_file() {
return true; //by default yes
}
+void Resource::connect_changed(const Callable &p_callable, uint32_t p_flags) {
+ if (!is_connected(CoreStringNames::get_singleton()->changed, p_callable) || p_flags & CONNECT_REFERENCE_COUNTED) {
+ connect(CoreStringNames::get_singleton()->changed, p_callable, p_flags);
+ }
+}
+
+void Resource::disconnect_changed(const Callable &p_callable) {
+ if (is_connected(CoreStringNames::get_singleton()->changed, p_callable)) {
+ disconnect(CoreStringNames::get_singleton()->changed, p_callable);
+ }
+}
+
void Resource::reset_state() {
}
+
Error Resource::copy_from(const Ref<Resource> &p_resource) {
ERR_FAIL_COND_V(p_resource.is_null(), ERR_INVALID_PARAMETER);
if (get_class() != p_resource->get_class()) {
return ERR_INVALID_PARAMETER;
}
- reset_state(); //may want to reset state
+ reset_state(); // May want to reset state.
List<PropertyInfo> pi;
p_resource->get_property_list(&pi);
@@ -322,23 +335,6 @@ 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 (const ObjectID &E : owners) {
- Object *obj = ObjectDB::get_instance(E);
- ERR_CONTINUE_MSG(!obj, "Object was deleted, while still owning a resource."); //wtf
- //TODO store string
- obj->call("resource_changed", Ref<Resource>(this));
- }
-}
-
#ifdef TOOLS_ENABLED
uint32_t Resource::hash_edited_version() const {
@@ -443,6 +439,7 @@ void Resource::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_local_to_scene"), &Resource::is_local_to_scene);
ClassDB::bind_method(D_METHOD("get_local_scene"), &Resource::get_local_scene);
ClassDB::bind_method(D_METHOD("setup_local_to_scene"), &Resource::setup_local_to_scene);
+
ClassDB::bind_method(D_METHOD("emit_changed"), &Resource::emit_changed);
ClassDB::bind_method(D_METHOD("duplicate", "subresources"), &Resource::duplicate, DEFVAL(false));
@@ -469,9 +466,6 @@ Resource::~Resource() {
ResourceCache::resources.erase(path_cache);
ResourceCache::lock.unlock();
}
- if (owners.size()) {
- WARN_PRINT("Resource is still owned.");
- }
}
HashMap<String, Resource *> ResourceCache::resources;