1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-26 15:46:23 +00:00

Make freed object different than null in comparison operators

This is so everything is consistent, as a freed object is not equivalent
to `null` in general. The booleanization of a freed object still returns
`false` to work as an easy check for validity of objects. Similarly, the
negation of a freed object returns `true`.

Also makes freed objects different from each other (if they are not the
same reference).
This commit is contained in:
George Marques
2023-02-24 15:41:48 -03:00
parent 970be7afdc
commit 150b50cfcd
2 changed files with 17 additions and 17 deletions

View File

@@ -931,7 +931,7 @@ bool Variant::is_zero() const {
return *reinterpret_cast<const ::RID *>(_data._mem) == ::RID();
}
case OBJECT: {
return _get_obj().obj == nullptr;
return get_validated_object() == nullptr;
}
case CALLABLE: {
return reinterpret_cast<const Callable *>(_data._mem)->is_null();