Skip to content
This repository was archived by the owner on May 24, 2021. It is now read-only.

Commit c695ae3

Browse files
committed
Destroy the child widgets *after* the child event is emitted.
1 parent 3bb23f6 commit c695ae3

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

enaml/core/object.py

+12-18
Original file line numberDiff line numberDiff line change
@@ -480,19 +480,16 @@ def remove_children(self, remove, destroy=True):
480480
else:
481481
new.append(child)
482482

483-
if destroy:
484-
for child in old:
485-
# Set the child's parent to None so that destroy does
486-
# not recurse back into a child manipulation method.
487-
child._parent = None
488-
child.destroy()
489-
else:
490-
for child in old:
491-
child._parent = None
483+
for child in old:
484+
child._parent = None
492485

493486
with ChildEventContext(self):
494487
self._children = tuple(new)
495488

489+
if destroy:
490+
for child in old:
491+
child.destroy()
492+
496493
def replace_children(self, remove, before, insert, destroy=True):
497494
""" Perform an 'atomic' remove and insert children operation.
498495
@@ -557,15 +554,8 @@ def replace_children(self, remove, before, insert, destroy=True):
557554
with ChildEventContext(old_parent):
558555
old_parent._children = old_kids
559556

560-
if destroy:
561-
for child in old:
562-
# Set the child's parent to None so that destroy does
563-
# not recurse back into a child manipulation method.
564-
child._parent = None
565-
child.destroy()
566-
else:
567-
for child in old:
568-
child._parent = None
557+
for child in old:
558+
child._parent = None
569559

570560
with ChildEventContext(self):
571561
self._children = tuple(new)
@@ -576,6 +566,10 @@ def replace_children(self, remove, before, insert, destroy=True):
576566
for child in insert_tup:
577567
child.initialize()
578568

569+
if destroy:
570+
for child in old:
571+
child.destroy()
572+
579573
#--------------------------------------------------------------------------
580574
# Messaging Methods
581575
#--------------------------------------------------------------------------

0 commit comments

Comments
 (0)