diff options
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/file_access.cpp | 7 | ||||
-rw-r--r-- | core/io/resource.cpp | 19 |
2 files changed, 21 insertions, 5 deletions
diff --git a/core/io/file_access.cpp b/core/io/file_access.cpp index 0e9084de84..3d10151327 100644 --- a/core/io/file_access.cpp +++ b/core/io/file_access.cpp @@ -133,8 +133,8 @@ Ref<FileAccess> FileAccess::open_encrypted(const String &p_path, ModeFlags p_mod Ref<FileAccessEncrypted> fae; fae.instantiate(); Error err = fae->open_and_parse(fa, p_key, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ); + last_file_open_error = err; if (err) { - last_file_open_error = err; return Ref<FileAccess>(); } return fae; @@ -149,8 +149,8 @@ Ref<FileAccess> FileAccess::open_encrypted_pass(const String &p_path, ModeFlags Ref<FileAccessEncrypted> fae; fae.instantiate(); Error err = fae->open_and_parse_password(fa, p_pass, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ); + last_file_open_error = err; if (err) { - last_file_open_error = err; return Ref<FileAccess>(); } return fae; @@ -161,9 +161,8 @@ Ref<FileAccess> FileAccess::open_compressed(const String &p_path, ModeFlags p_mo fac.instantiate(); fac->configure("GCPF", (Compression::Mode)p_compress_mode); Error err = fac->open_internal(p_path, p_mode_flags); - + last_file_open_error = err; if (err) { - last_file_open_error = err; return Ref<FileAccess>(); } diff --git a/core/io/resource.cpp b/core/io/resource.cpp index 4abcbffb61..6b8ec8d5f6 100644 --- a/core/io/resource.cpp +++ b/core/io/resource.cpp @@ -542,9 +542,26 @@ Ref<Resource> ResourceCache::get_ref(const String &p_path) { void ResourceCache::get_cached_resources(List<Ref<Resource>> *p_resources) { lock.lock(); + + LocalVector<String> to_remove; + for (KeyValue<String, Resource *> &E : resources) { - p_resources->push_back(Ref<Resource>(E.value)); + Ref<Resource> ref = Ref<Resource>(E.value); + + if (!ref.is_valid()) { + // This resource is in the process of being deleted, ignore its existence + E.value->path_cache = String(); + to_remove.push_back(E.key); + continue; + } + + p_resources->push_back(ref); + } + + for (const String &E : to_remove) { + resources.erase(E); } + lock.unlock(); } |