mirror of
https://github.com/centau/vide.git
synced 2026-10-20 17:34:08 +00:00
Merge c3c09de1ba into a4151bd41e
This commit is contained in:
commit
c203241e1c
2 changed files with 30 additions and 3 deletions
|
|
@ -62,7 +62,7 @@ local function update_children_effect(p: {
|
||||||
|
|
||||||
push_cleanup(assert(get_scope()), function()
|
push_cleanup(assert(get_scope()), function()
|
||||||
for child in node.cache.cur_children_set do
|
for child in node.cache.cur_children_set do
|
||||||
child.Parent = nil
|
if child.Parent == p.instance then child.Parent = nil end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
@ -71,7 +71,7 @@ local function update_children_effect(p: {
|
||||||
process_child(new_children)
|
process_child(new_children)
|
||||||
|
|
||||||
for child in cur_children_set do
|
for child in cur_children_set do
|
||||||
child.Parent = nil -- unparent all children that weren't in the new children set
|
if child.Parent == p.instance then child.Parent = nil end -- unparent all children that weren't in the new children set
|
||||||
end
|
end
|
||||||
|
|
||||||
table.clear(cur_children_set) -- clear cache, preserve capacity
|
table.clear(cur_children_set) -- clear cache, preserve capacity
|
||||||
|
|
@ -116,7 +116,7 @@ return {
|
||||||
|
|
||||||
push_cleanup(assert_stable_scope(), function()
|
push_cleanup(assert_stable_scope(), function()
|
||||||
for child in node.cache.cur_children_set do
|
for child in node.cache.cur_children_set do
|
||||||
child.Parent = nil
|
if child.Parent == instance then child.Parent = nil end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1050,6 +1050,33 @@ TEST("create()", wrap_root(function()
|
||||||
CHECK(parent:FindFirstChild "c")
|
CHECK(parent:FindFirstChild "c")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do CASE "children moved to another parent"
|
||||||
|
local other = create "Frame" {}
|
||||||
|
|
||||||
|
local child = create "Frame" {}
|
||||||
|
local children_a = source { child }
|
||||||
|
local children_b = source {}
|
||||||
|
create "Frame" { children_a }
|
||||||
|
local parent_b = create "Frame" { children_b }
|
||||||
|
|
||||||
|
children_b { child }
|
||||||
|
children_a {}
|
||||||
|
CHECK(child.Parent == parent_b)
|
||||||
|
|
||||||
|
local a = create "Frame" {}
|
||||||
|
local b = create "Frame" {}
|
||||||
|
local destroy = root(function()
|
||||||
|
create "Frame" { function() return a end }
|
||||||
|
create "Frame" { function() return { function() return b end } end }
|
||||||
|
end)
|
||||||
|
|
||||||
|
a.Parent = other
|
||||||
|
b.Parent = other
|
||||||
|
destroy()
|
||||||
|
CHECK(a.Parent == other)
|
||||||
|
CHECK(b.Parent == other)
|
||||||
|
end
|
||||||
|
|
||||||
do CASE "garbage collection test"
|
do CASE "garbage collection test"
|
||||||
local wref
|
local wref
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue