From af331777b6fa52a81140a8e99af339b8d69db046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=84=B8=EC=A0=A4=EA=B7=80=20=EA=B3=A0=EC=96=91=EC=9D=B4?= =?UTF-8?q?=EB=93=A4?= <46598063+qwreey75@users.noreply.github.com> Date: Fri, 24 Dec 2021 20:04:08 +0900 Subject: [PATCH] bug fix --- src/class.lua | 8 ++++---- src/mount.lua | 15 ++++++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/class.lua b/src/class.lua index 03a4e3d..2d7e68c 100644 --- a/src/class.lua +++ b/src/class.lua @@ -193,11 +193,11 @@ function module.init(shared) rawset(self,"__holder",object); if parent then rawset(self,"__parent",parent); - mount(item,parent) + mount(self,parent) end -- prevent gc ((type(object) == "table" and object.__object) or object):GetPropertyChamgedSignal "ClassName":Connect(function() - return item; + return self; end); return self; end @@ -222,13 +222,13 @@ function module.init(shared) if child then for _,v in pairs(child) do if v then - ((type(v) == "table") and rawget(v,"__object") or v).Parent = object; + v.Parent = object; end end end -- prevnet gc ((type(object) == "table" and object.__object) or object):GetPropertyChamgedSignal "ClassName":Connect(function() - return item; + return self; end); if lastObject then -- remove old instance self:Destroy(lastObject); diff --git a/src/mount.lua b/src/mount.lua index 2f13faf..3440783 100644 --- a/src/mount.lua +++ b/src/mount.lua @@ -33,9 +33,22 @@ function module.init(shared) local thisO = this; if type(this) == "table" then thisO = this.__object; + local parent = rawget(this,"__parent"); + if type(parent) == "table" then + local parentChild = rawget(parent,"__child"); + if parentChild then + for i,v in pairs(parentChild) do + if v == this then + parentChild[i] = nil; + end + end + end + end rawset(this,"__parent",to); end - thisO.Parent = inst or getHolder(to); + if thisO then + thisO.Parent = inst or getHolder(to); + end if type(to) == "table" then local child = rawget(to,"__child"); if not child then