Author: bugman Date: Mon Aug 8 10:13:21 2011 New Revision: 14248 URL: http://svn.gna.org/viewcvs/relax?rev=14248&view=rev Log: The spin viewer tree update() method now acquires both the pipe and spin locks. This prevents a major source of race conditions. Modified: branches/gui_testing/gui/spin_viewer/tree.py Modified: branches/gui_testing/gui/spin_viewer/tree.py URL: http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/spin_viewer/tree.py?rev=14248&r1=14247&r2=14248&view=diff ============================================================================== --- branches/gui_testing/gui/spin_viewer/tree.py (original) +++ branches/gui_testing/gui/spin_viewer/tree.py Mon Aug 8 10:13:21 2011 @@ -647,23 +647,32 @@ def update(self, pipe_name=None): """Update the tree view using the given data pipe.""" - # The data pipe. - if not pipe_name: - pipe = cdp - else: - pipe = get_pipe(pipe_name) - - # No data pipe, so delete everything and return. - if not pipe: - self.tree.DeleteChildren(self.root) - return - - # Update the molecules. - for mol, mol_id in molecule_loop(return_id=True): - self.update_mol(mol, mol_id) - - # Remove any deleted molecules. - self.prune_mol() + # Acquire the pipe and spin locks. + status.pipe_lock.acquire() + status.spin_lock.acquire() + try: + # The data pipe. + if not pipe_name: + pipe = cdp + else: + pipe = get_pipe(pipe_name) + + # No data pipe, so delete everything and return. + if not pipe: + self.tree.DeleteChildren(self.root) + return + + # Update the molecules. + for mol, mol_id in molecule_loop(return_id=True): + self.update_mol(mol, mol_id) + + # Remove any deleted molecules. + self.prune_mol() + + # Release the locks. + finally: + status.pipe_lock.release() + status.spin_lock.release() def update_mol(self, mol, mol_id):