Merge pull request #96076 from AThousandShips/improve_null_check_core_drivers

[Core,Drivers] Improve use of `Ref.is_null/valid`
This commit is contained in:
Thaddeus Crews
2024-12-23 11:14:58 -06:00
14 changed files with 37 additions and 37 deletions

View File

@@ -231,7 +231,7 @@ void Resource::reload_from_file() {
Ref<Resource> s = ResourceLoader::load(ResourceLoader::path_remap(path), get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);
if (!s.is_valid()) {
if (s.is_null()) {
return;
}
@@ -651,7 +651,7 @@ Ref<Resource> ResourceCache::get_ref(const String &p_path) {
ref = Ref<Resource>(*res);
}
if (res && !ref.is_valid()) {
if (res && ref.is_null()) {
// This resource is in the process of being deleted, ignore its existence
(*res)->path_cache = String();
resources.erase(p_path);
@@ -670,7 +670,7 @@ void ResourceCache::get_cached_resources(List<Ref<Resource>> *p_resources) {
for (KeyValue<String, Resource *> &E : resources) {
Ref<Resource> ref = Ref<Resource>(E.value);
if (!ref.is_valid()) {
if (ref.is_null()) {
// This resource is in the process of being deleted, ignore its existence
E.value->path_cache = String();
to_remove.push_back(E.key);