1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-08 12:40:44 +00:00

Improve use of Ref.is_null/valid

Use `is_null` over `!is_valid` and vice versa.
This commit is contained in:
A Thousand Ships
2024-08-25 14:15:10 +02:00
committed by AThousandShips
parent 0f95e9f8e6
commit a1846b27ea
177 changed files with 517 additions and 519 deletions

View File

@@ -85,7 +85,7 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene
ps = ResourceLoader::load(path, "PackedScene");
}
if (!ps.is_valid()) {
if (ps.is_null()) {
return nullptr;
}
Node *instance = ps->instantiate();
@@ -163,7 +163,7 @@ void InstancePlaceholder::set_value_on_instance(InstancePlaceholder *p_placehold
switch (current_type) {
case Variant::Type::NIL: {
Ref<Resource> resource = p_set.value;
if (placeholder_type != Variant::Type::NODE_PATH && !resource.is_valid()) {
if (placeholder_type != Variant::Type::NODE_PATH && resource.is_null()) {
break;
}
// If it's nil but we have a NodePath or a Resource, we guess what works.