Skip to content

Commit 08b5392

Browse files
修改:覆写激活和禁用时应该同时处理Owner上的引用
1 parent 725246d commit 08b5392

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Plugins/UnLua/Source/UnLua/Private/LuaOverridesClass.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ void ULuaOverridesClass::SetActive(const bool bActive)
4949
}
5050

5151
Class->ClearFunctionMapsCaches();
52+
if (bActive)
53+
AddToOwner();
54+
else
55+
RemoveFromOwner();
5256
}
5357

5458
void ULuaOverridesClass::BeginDestroy()
@@ -71,8 +75,17 @@ void ULuaOverridesClass::AddToOwner()
7175
auto Field = &(Class->Children);
7276
#endif
7377
while (*Field)
78+
{
79+
if (*Field == this)
80+
{
81+
Field = nullptr;
82+
break;
83+
}
7484
Field = &(*Field)->Next;
75-
*Field = this;
85+
}
86+
87+
if (Field)
88+
*Field = this;
7689

7790
if (Class->IsRooted() || GUObjectArray.IsDisregardForGC(Class))
7891
AddToRoot();

0 commit comments

Comments
 (0)