OSDN Git Service

Correctly handle deletion of a configuration profile when it is both manually activat...
authorJames Teh <jamie@nvaccess.org>
Tue, 22 Oct 2013 04:34:11 +0000 (14:34 +1000)
committerJames Teh <jamie@nvaccess.org>
Tue, 22 Oct 2013 04:34:11 +0000 (14:34 +1000)
Previously, the profile remained active even though it had been deleted. In the profile list, it appeared as if nothing was active.
Re #667.

source/config/__init__.py

index 2458d6d..8aaf5f3 100644 (file)
@@ -610,13 +610,14 @@ class ConfigManager(object):
                                del allTriggers[trigSpec]\r
                        self.saveProfileTriggers()\r
                # Check if this profile was active.\r
-               for index, profile in enumerate(self.profiles):\r
-                       if profile.name == name:\r
-                               break\r
-               else:\r
+               wasActive = False\r
+               for index in xrange(len(self.profiles) - 1, -1, -1):\r
+                       if self.profiles[index].name == name:\r
+                               # Deactivate it.\r
+                               del self.profiles[index]\r
+                               wasActive = True\r
+               if not wasActive:\r
                        return\r
-               # Deactivate it.\r
-               del self.profiles[index]\r
                self._handleProfileSwitch()\r
 \r
        def renameProfile(self, oldName, newName):\r