mailr14309 - /branches/gui_testing/gui/relax_gui.py


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

Header


Content

Posted by edward on August 10, 2011 - 14:15:
Author: bugman
Date: Wed Aug 10 14:15:51 2011
New Revision: 14309

URL: http://svn.gna.org/viewcvs/relax?rev=14309&view=rev
Log:
The GUI now returns to normal when opening an invalid or incompatible save 
file.


Modified:
    branches/gui_testing/gui/relax_gui.py

Modified: branches/gui_testing/gui/relax_gui.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/relax_gui.py?rev=14309&r1=14308&r2=14309&view=diff
==============================================================================
--- branches/gui_testing/gui/relax_gui.py (original)
+++ branches/gui_testing/gui/relax_gui.py Wed Aug 10 14:15:51 2011
@@ -58,7 +58,7 @@
 from gui.icons import Relax_task_bar_icon, relax_icons
 from gui.menu import Menu
 from gui.message import error_message, Question
-from gui.misc import open_file
+from gui.misc import gui_to_str, open_file, protected_exec
 from gui import paths
 from gui.pipe_editor import Pipe_editor
 from gui.references import References
@@ -521,7 +521,7 @@
                 return
 
             # The file.
-            file_name = dialog.get_file()
+            file_name = gui_to_str(dialog.get_file())
 
         # Yield to allow the cursor to be changed.
         wx.Yield()
@@ -530,27 +530,30 @@
         wx.BeginBusyCursor()
         self.Freeze()
 
-        # Delete the current tabs.
-        self.analysis.delete_all()
-
-        # Reset the relax data store.
-        reset()
-
-        # The new save file name.
-        self.save_file = file_name
-
-        # Load the relax state.
-        state.load_state(file_name, verbosity=0)
-
-        # Reconstruct the analyses.
-        self.analysis.load_from_store()
-
-        # Update the core of the GUI to match the new data store.
-        self.sync_ds(upload=False)
+        # Make sure the GUI returns to normal if a failure occurs.
+        try:
+            # Delete the current tabs.
+            self.analysis.delete_all()
+
+            # Reset the relax data store.
+            reset()
+
+            # The new save file name.
+            self.save_file = file_name
+
+            # Load the relax state.
+            protected_exec(state.load_state, file_name, verbosity=0)
+
+            # Reconstruct the analyses.
+            self.analysis.load_from_store()
+
+            # Update the core of the GUI to match the new data store.
+            self.sync_ds(upload=False)
 
         # Reset the cursor, and thaw the GUI.
-        self.Thaw()
-        wx.EndBusyCursor()
+        finally:
+            self.Thaw()
+            wx.EndBusyCursor()
 
 
     def state_save(self):




Related Messages


Powered by MHonArc, Updated Wed Aug 10 14:20:02 2011