# HG changeset patch # User Thinker K.F. Li # Date 1294729347 -28800 # Node ID 8755415b5e996c2f5b5f7d9f91e62231bf6e2469 # Parent a8e01435e84ea1c708e6bcef28d8e82b39bd9d5a More check for remvoing scene and scene group. - Without this check, it can make Inkscape crashed if we remove a node that had been removed. - Check whether it owns a parent node before removing. - A removed node has no parent node. diff -r a8e01435e84e -r 8755415b5e99 pyink/domview.py --- a/pyink/domview.py Tue Jan 11 12:35:28 2011 +0800 +++ b/pyink/domview.py Tue Jan 11 15:02:27 2011 +0800 @@ -410,7 +410,12 @@ pass pass + ## \brief Remove scene node from DOM-tree. + # def rm_scene_node(self, scene_node): + if not scene_node.parent(): + return # without this, may crash the Inkscape. + self._scenes_node.removeChild(scene_node) for layer in self._layers: try: @@ -422,12 +427,26 @@ pass pass + ## \brief Remove scene node and asssociated scene group from DOM. + # + # It will remove as many as possible. Does not complain about + # error in the procedure of removing. + # def rm_scene_node_n_group(self, scene_node): scene_group_id = scene_node.getAttribute('ref') - scene_group_node = self.get_node(scene_group_id) - scene_group_node.parent().removeChild(scene_group_node) + try: + scene_group_node = self.get_node(scene_group_id) + if scene_group_node.parent(): # Check it, or crash the + # Inkscape. + scene_group_node.parent().removeChild(scene_group_node) + pass + except: + pass - self.rm_scene_node(scene_node) + try: + self.rm_scene_node(scene_node) + except: + pass pass ## \brief Create and add a svg:g for a scene under a group for a layer.