Author: bugman Date: Wed Jan 14 17:00:51 2015 New Revision: 27167 URL: http://svn.gna.org/viewcvs/relax?rev=27167&view=rev Log: Fix for bug #23187 (https://gna.org/bugs/?23187). This is the problem whereby opening the spin viewer window, deleting a residue, and then reopening the spin viewer crashes relax. This change completes the spin viewer update_*() functions. The prune_list variable was initialised but not used. Now it is used to store the keys of the items to delete, and then the items are deleted at the end in a new loop so that the loop over the dictionary keys is not corrupted. Modified: trunk/gui/spin_viewer/tree.py Modified: trunk/gui/spin_viewer/tree.py URL: http://svn.gna.org/viewcvs/relax/trunk/gui/spin_viewer/tree.py?rev=27167&r1=27166&r2=27167&view=diff ============================================================================== --- trunk/gui/spin_viewer/tree.py (original) +++ trunk/gui/spin_viewer/tree.py Wed Jan 14 17:00:51 2015 @@ -740,10 +740,14 @@ # Get the python data. info = self.tree.GetItemPyData(key) - # Prune if it has been removed. + # Add to the prune list if it has been removed. if info['id'] not in mol_ids: - self.tree.Delete(key) - self.tree_ids.pop(key) + prune_list.append(key) + + # Delete the data. + for key in prune_list: + self.tree.Delete(key) + self.tree_ids.pop(key) def prune_res(self, mol_branch_id, mol_id): @@ -764,10 +768,14 @@ # Get the residue. res = return_residue(info['id']) - # Prune if it has been removed or renamed/renumbered. + # Add to the prune list if it has been removed or renamed/renumbered. if res == None or res.name != info['res_name'] or res.num != info['res_num']: - self.tree.Delete(key) - self.tree_ids[mol_branch_id].pop(key) + prune_list.append(key) + + # Delete the data. + for key in prune_list: + self.tree.Delete(key) + self.tree_ids[mol_branch_id].pop(key) def prune_spin(self, mol_branch_id, res_branch_id, res_id): @@ -790,10 +798,14 @@ # Get the spin. spin = return_spin(info['id']) - # Prune if it has been removed or renamed/renumbered. + # Add to the prune list if it has been removed or renamed/renumbered. if spin == None or spin.name != info['spin_name'] or spin.num != info['spin_num']: - self.tree.Delete(key) - self.tree_ids[mol_branch_id][res_branch_id].pop(key) + prune_list.append(key) + + # Delete the data. + for key in prune_list: + self.tree.Delete(key) + self.tree_ids[mol_branch_id][res_branch_id].pop(key) def set_bitmap_mol(self, mol_branch_id, select=True):