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

Commit

Permalink
Destroy the child widgets *after* the child event is emitted.
Browse files Browse the repository at this point in the history
  • Loading branch information
sccolbert committed Nov 16, 2012
1 parent 3bb23f6 commit c695ae3
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions enaml/core/object.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,19 +480,16 @@ def remove_children(self, remove, destroy=True):
else:
new.append(child)

if destroy:
for child in old:
# Set the child's parent to None so that destroy does
# not recurse back into a child manipulation method.
child._parent = None
child.destroy()
else:
for child in old:
child._parent = None
for child in old:
child._parent = None

with ChildEventContext(self):
self._children = tuple(new)

if destroy:
for child in old:
child.destroy()

def replace_children(self, remove, before, insert, destroy=True):
""" Perform an 'atomic' remove and insert children operation.
Expand Down Expand Up @@ -557,15 +554,8 @@ def replace_children(self, remove, before, insert, destroy=True):
with ChildEventContext(old_parent):
old_parent._children = old_kids

if destroy:
for child in old:
# Set the child's parent to None so that destroy does
# not recurse back into a child manipulation method.
child._parent = None
child.destroy()
else:
for child in old:
child._parent = None
for child in old:
child._parent = None

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

if destroy:
for child in old:
child.destroy()

#--------------------------------------------------------------------------
# Messaging Methods
#--------------------------------------------------------------------------
Expand Down

0 comments on commit c695ae3

Please sign in to comment.