From b4bc0a44f259f9f1725330556539fe6b9bb7408a Mon Sep 17 00:00:00 2001 From: johnche Date: Tue, 3 Dec 2024 19:40:49 +0800 Subject: [PATCH] =?UTF-8?q?[unreal]=E5=A4=84=E7=90=86=E5=86=85=E5=AD=98?= =?UTF-8?q?=E9=87=8D=E7=94=A8=E5=AF=BC=E8=87=B4=E7=9A=84Check=20failed:=20?= =?UTF-8?q?Handle=20not=20reset=20in=20first=20callback.=20See=20comments?= =?UTF-8?q?=20on=20|v8::WeakCallbackInfo|=20fix=20https://github.com/Tence?= =?UTF-8?q?nt/puerts/issues/1930?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- unity/native_src/Src/CppObjectMapper.cpp | 3 ++- unreal/Puerts/Source/JsEnv/Private/CppObjectMapper.cpp | 3 ++- unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp | 7 ++++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/unity/native_src/Src/CppObjectMapper.cpp b/unity/native_src/Src/CppObjectMapper.cpp index d974405e59..c1c06a854f 100644 --- a/unity/native_src/Src/CppObjectMapper.cpp +++ b/unity/native_src/Src/CppObjectMapper.cpp @@ -340,7 +340,8 @@ void FCppObjectMapper::BindCppObject( FObjectCacheNode* CacheNodePtr; if (Iter != CDataCache.end()) { - CacheNodePtr = Iter->second.Add(ClassDefinition->TypeId); + auto Temp = Iter->second.Find(ClassDefinition->TypeId); + CacheNodePtr = Temp ? Temp : Iter->second.Add(ClassDefinition->TypeId); } else { diff --git a/unreal/Puerts/Source/JsEnv/Private/CppObjectMapper.cpp b/unreal/Puerts/Source/JsEnv/Private/CppObjectMapper.cpp index 71380161fc..787ac45776 100644 --- a/unreal/Puerts/Source/JsEnv/Private/CppObjectMapper.cpp +++ b/unreal/Puerts/Source/JsEnv/Private/CppObjectMapper.cpp @@ -304,7 +304,8 @@ void FCppObjectMapper::BindCppObject( FObjectCacheNode* CacheNodePtr; if (Iter != CDataCache.end()) { - CacheNodePtr = &Iter->second; + auto Temp = Iter->second.Find(ClassDefinition->TypeId); + CacheNodePtr = Temp ? Temp : Iter->second.Add(ClassDefinition->TypeId); } else { diff --git a/unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp b/unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp index 1ea1ae8ce6..56a8669350 100644 --- a/unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp +++ b/unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp @@ -2913,7 +2913,12 @@ void FJsEnvImpl::BindStruct( } #endif auto CacheNodePtr = StructCache.Find(Ptr); - if (!CacheNodePtr) + if (CacheNodePtr) + { + auto Temp = CacheNodePtr->Find(ScriptStructWrapper->Struct.Get()); + CacheNodePtr = Temp ? Temp : CacheNodePtr->Add(ScriptStructWrapper->Struct.Get()); + } + else { CacheNodePtr = &StructCache.Emplace(Ptr, FObjectCacheNode(ScriptStructWrapper->Struct.Get())); }