comparison 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
comparison
equal deleted inserted replaced
1259:df474448364e 1260:bbd6bc0d079a
502 ## \brief Remove layer and associated scene nodes and scene groups. 502 ## \brief Remove layer and associated scene nodes and scene groups.
503 # 503 #
504 def rm_layer(self, layer_idx): 504 def rm_layer(self, layer_idx):
505 layers = self._layers 505 layers = self._layers
506 506
507 for layer in layers: 507 layer = self._layers[layer_idx]
508 for scene_node in layer.scenes: 508 for scene_node in layer.scenes:
509 scene_group_id = scene_node.getAttribute('ref') 509 scene_group_id = scene_node.getAttribute('ref')
510 scene_group_node = self.get_node(scene_group_id) 510 try:
511 scene_group_node.parent().removeChild(scene_group_node) 511 scene_group_node = self.get_node(scene_group_id)
512 512 if scene_group_node.parent(): # keep from crashing
513 scene_node.parent().removeChild(scene_node) 513 scene_group_node.parent().removeChild(scene_group_node)
514 pass
515 except:
516 pass
517
518 if scene_node.parent(): # keep from crashing
519 scene_node.parent().removeChild(scene_node)
514 pass 520 pass
515 pass 521 pass
516 522
517 del layers[layer_idx] 523 del layers[layer_idx]
518 524