commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r9449 - trunk/gnue-forms/src/GFObjects


From: reinhard
Subject: [gnue] r9449 - trunk/gnue-forms/src/GFObjects
Date: Tue, 27 Mar 2007 13:12:35 -0500 (CDT)

Author: reinhard
Date: 2007-03-27 13:12:35 -0500 (Tue, 27 Mar 2007)
New Revision: 9449

Modified:
   trunk/gnue-forms/src/GFObjects/commanders.py
Log:
Fix behaviour of toggle style toolbar buttons in case firing the action causes
an exception.


Modified: trunk/gnue-forms/src/GFObjects/commanders.py
===================================================================
--- trunk/gnue-forms/src/GFObjects/commanders.py        2007-03-27 18:09:57 UTC 
(rev 9448)
+++ trunk/gnue-forms/src/GFObjects/commanders.py        2007-03-27 18:12:35 UTC 
(rev 9449)
@@ -290,18 +290,30 @@
 
     def __fire(self):
 
-        if self.state and self.__action_off is not None:
-            self.__action_off.run()
-            self.state = False
-            if self.uiWidget is not None:
-                self.uiWidget._ui_switch_off_()
-        elif self.__action is not None:
-            self.__action.run()
-            if self.__action_off is not None:
-                self.state = True
+        try:
+            if self.state and self.__action_off is not None:
+                try:
+                    self.__action_off.run()
+                except Exception:
+                    self.uiWidget._ui_switch_on_()
+                    raise
+                self.state = False
                 if self.uiWidget is not None:
-                    self.uiWidget._ui_switch_on_()
-        self.update_status()
+                    self.uiWidget._ui_switch_off_()
+            elif self.__action is not None:
+                try:
+                    self.__action.run()
+                except:
+                    self.uiWidget._ui_switch_off_()
+                    raise
+                if self.__action_off is not None:
+                    self.state = True
+                    if self.uiWidget is not None:
+                        self.uiWidget._ui_switch_on_()
+        finally:
+            # Do this also in case of exceptions in case the action code has
+            # meddled with the enabled/disabled status of the actions.
+            self.update_status()
 
 
 # =============================================================================





reply via email to

[Prev in Thread] Current Thread [Next in Thread]