Skip to content

Commit

Permalink
[unreal]处理内存重用导致的Check failed: Handle not reset in first callback. Se…
Browse files Browse the repository at this point in the history
…e comments on |v8::WeakCallbackInfo| fix #1930
  • Loading branch information
chexiongsheng committed Dec 3, 2024
1 parent eefed71 commit b4bc0a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion unity/native_src/Src/CppObjectMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion unreal/Puerts/Source/JsEnv/Private/CppObjectMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
7 changes: 6 additions & 1 deletion unreal/Puerts/Source/JsEnv/Private/JsEnvImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
Expand Down

0 comments on commit b4bc0a4

Please sign in to comment.