mailr14691 - /1.3/gui/analyses/__init__.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on September 19, 2011 - 12:20:
Author: bugman
Date: Mon Sep 19 12:20:12 2011
New Revision: 14691

URL: http://svn.gna.org/viewcvs/relax?rev=14691&view=rev
Log:
Analysis tabs are now removed if the associated data pipe is deleted.

This avoids nasty GUI crashing.


Modified:
    1.3/gui/analyses/__init__.py

Modified: 1.3/gui/analyses/__init__.py
URL: 
http://svn.gna.org/viewcvs/relax/1.3/gui/analyses/__init__.py?rev=14691&r1=14690&r2=14691&view=diff
==============================================================================
--- 1.3/gui/analyses/__init__.py (original)
+++ 1.3/gui/analyses/__init__.py Mon Sep 19 12:20:12 2011
@@ -82,6 +82,9 @@
         self.name = 'notebook page switcher'
         status.observers.pipe_alteration.register(self.name, 
self.pipe_switch)
 
+        # Register a method for removing analyses if the associated pipe is 
deleted.
+        status.observers.pipe_alteration.register('notebook pipe deletion', 
self.pipe_deletion)
+
         # Register the deletion of all analyses for the reset status 
observer.
         status.observers.reset.register('gui analyses', self.post_reset)
 
@@ -179,7 +182,8 @@
             self._analyses[index].delete()
 
         # Delete all data pipes associated with the analysis.
-        pipes.delete(ds.relax_gui.analyses[index].pipe_name)
+        if pipes.has_pipe(ds.relax_gui.analyses[index].pipe_name):
+            pipes.delete(ds.relax_gui.analyses[index].pipe_name)
 
         # Delete the data store object.
         ds.relax_gui.analyses.pop(index)
@@ -502,6 +506,23 @@
         return ds.relax_gui.analyses[index].analysis_name
 
 
+    def pipe_deletion(self):
+        """Remove analysis tabs for which the associated data pipe has been 
deleted."""
+
+        # Loop over the analyses, noting which no longer have a data pipe.
+        del_list = []
+        for i in range(self._num_analyses):
+            if not pipes.has_pipe(ds.relax_gui.analyses[i].pipe_name):
+                del_list.append(i)
+
+        # Reverse the order of the list so the removal works correctly.
+        del_list.reverse()
+
+        # Delete the analyses.
+        for index in del_list:
+            self.delete_analysis(index)
+
+
     def pipe_switch(self, pipe=None):
         """Switch the page to the given or current data pipe.
 




Related Messages


Powered by MHonArc, Updated Mon Sep 19 12:40:02 2011