From b8d7fd89f0b84162bfaccb4c330298fb8bd72db1 Mon Sep 17 00:00:00 2001 From: xLuxy <67131061+xLuxy@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:19:21 +0200 Subject: [PATCH] fix(shared): Fix GetBaseObjectOrNull throwing when entity could not be created --- shared/V8ResourceImpl.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/shared/V8ResourceImpl.cpp b/shared/V8ResourceImpl.cpp index 56817c11..b0fe1b13 100644 --- a/shared/V8ResourceImpl.cpp +++ b/shared/V8ResourceImpl.cpp @@ -185,9 +185,14 @@ void V8ResourceImpl::BindEntity(v8::Local val, alt::IBaseObject* han v8::Local V8ResourceImpl::GetBaseObjectOrNull(alt::IBaseObject* handle) { - if(handle == nullptr || handle->IsRemoved()) return v8::Null(isolate); - else - return GetOrCreateEntity(handle)->GetJSVal(isolate); + if(handle == nullptr || handle->IsRemoved()) + return v8::Null(isolate); + + V8Entity* entity = GetOrCreateEntity(handle); + if (entity) + return entity->GetJSVal(isolate); + + return v8::Null(isolate); } v8::Local V8ResourceImpl::CreateVector3(alt::Vector3f vec)