Merge pull request #38350 from RandomShaper/fix_variant_to_rid

Fix errors in Variant to RID conversion
This commit is contained in:
Rémi Verschelde 2020-04-30 16:25:29 +02:00 committed by GitHub
commit 510406af28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -1762,11 +1762,12 @@ Variant::operator RID() const {
return _get_obj().ref.get_rid(); return _get_obj().ref.get_rid();
} else { } else {
#ifdef DEBUG_ENABLED #ifdef DEBUG_ENABLED
Object *obj = _get_obj().rc->get_ptr(); Object *obj = likely(_get_obj().rc) ? _get_obj().rc->get_ptr() : NULL;
if (unlikely(!obj)) { if (unlikely(!obj)) {
if (ScriptDebugger::get_singleton() && _get_obj().rc && !ObjectDB::get_instance(_get_obj().rc->instance_id)) { if (ScriptDebugger::get_singleton() && _get_obj().rc && !ObjectDB::get_instance(_get_obj().rc->instance_id)) {
WARN_PRINT("Attempted get RID on a deleted object."); WARN_PRINT("Attempted get RID on a deleted object.");
} }
return RID();
} }
#else #else
Object *obj = _get_obj().obj; Object *obj = _get_obj().obj;