Skip to content

Commit c559f77

Browse files
committed
Always remove children from old parent
1 parent 67e7a71 commit c559f77

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

addons/pandora/backend/entity_backend.gd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,16 +177,25 @@ func move_entity(source: PandoraEntity, target: PandoraEntity, drop_section: Dro
177177
if not target is PandoraCategory:
178178
push_error("Unable to move entity to entity")
179179
return
180+
var old_parent = get_category(source._category_id)
181+
if old_parent:
182+
old_parent._children.erase(source)
180183
source.set_category(target)
181184
source.set_index(target._children.size())
182185
elif drop_section == DropSection.ABOVE:
183186
if source._category_id != target._category_id:
187+
var old_parent = get_category(source._category_id)
188+
if old_parent:
189+
old_parent._children.erase(source)
184190
source.set_category(target.get_category())
185191
var old_index = source._index
186192
source.set_index(target._index)
187193
reorder_entities(source, old_index)
188194
elif drop_section == DropSection.BELOW:
189195
if source._category_id != target._category_id:
196+
var old_parent = get_category(source._category_id)
197+
if old_parent:
198+
old_parent._children.erase(source)
190199
source.set_category(target.get_category())
191200
var old_index = source._index
192201
source.set_index(target._index + 1)

0 commit comments

Comments
 (0)