Mercurial > MadButterfly
diff pyink/domview.py @ 1260:bbd6bc0d079a
Fix bug of removing layer.
- It removes content of all layers.
- Only specified layer should be removed.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 11 Jan 2011 17:57:11 +0800 |
parents | df474448364e |
children | 2f861eea1214 |
line wrap: on
line diff
--- a/pyink/domview.py Tue Jan 11 17:39:06 2011 +0800 +++ b/pyink/domview.py Tue Jan 11 17:57:11 2011 +0800 @@ -504,13 +504,19 @@ def rm_layer(self, layer_idx): layers = self._layers - for layer in layers: - for scene_node in layer.scenes: - scene_group_id = scene_node.getAttribute('ref') - scene_group_node = self.get_node(scene_group_id) - scene_group_node.parent().removeChild(scene_group_node) - - scene_node.parent().removeChild(scene_node) + layer = self._layers[layer_idx] + for scene_node in layer.scenes: + scene_group_id = scene_node.getAttribute('ref') + try: + scene_group_node = self.get_node(scene_group_id) + if scene_group_node.parent(): # keep from crashing + scene_group_node.parent().removeChild(scene_group_node) + pass + except: + pass + + if scene_node.parent(): # keep from crashing + scene_node.parent().removeChild(scene_node) pass pass