Add try/finally for every setOverrideCursor/restoreOverrideCursor.
[bertos.git] / wizard / BToolchainPage.py
index f85dbb1f30c44b417d01fb7c8b88eda138e65c81..88be219efe4a323743437ac06a47f124054f90b3 100644 (file)
@@ -155,10 +155,12 @@ class BToolchainPage(BWizardPage):
         Slot called when the user clicks on the validate button. It starts the
         toolchain validation procedure for all the toolchains.
         """
         Slot called when the user clicks on the validate button. It starts the
         toolchain validation procedure for all the toolchains.
         """
-        QApplication.instance().setOverrideCursor(Qt.WaitCursor)
-        for i in range(self.pageContent.toolchainList.count()):
-            self.validateToolchain(i)
-        QApplication.instance().restoreOverrideCursor()
+        try:
+            QApplication.instance().setOverrideCursor(Qt.WaitCursor)
+            for i in range(self.pageContent.toolchainList.count()):
+                self.validateToolchain(i)
+        finally:
+            QApplication.instance().restoreOverrideCursor()
 
     ####
 
 
     ####
 
@@ -174,13 +176,18 @@ class BToolchainPage(BWizardPage):
                 toolchains[toolchain] = True
         sel_toolchain = self.projectInfo("TOOLCHAIN")
         for key, value in toolchains.items():
                 toolchains[toolchain] = True
         sel_toolchain = self.projectInfo("TOOLCHAIN")
         for key, value in toolchains.items():
-            item = QListWidgetItem(key)
-            item.setData(Qt.UserRole, qvariant_converter.convertStringDict({"path": key}))
-            self.pageContent.toolchainList.addItem(item)
-            if sel_toolchain and sel_toolchain["path"] == key:
-                self.pageContent.toolchainList.setCurrentItem(item)
-            if value:
-                self.validateToolchain(self.pageContent.toolchainList.row(item))
+            if os.path.exists(key):
+                item = QListWidgetItem(key)
+                item.setData(Qt.UserRole, qvariant_converter.convertStringDict({"path": key}))
+                self.pageContent.toolchainList.addItem(item)
+                if sel_toolchain and sel_toolchain["path"] == key:
+                    self.pageContent.toolchainList.setCurrentItem(item)
+                if value:
+                    self.validateToolchain(self.pageContent.toolchainList.row(item))
+
+    def currentToolchain(self):
+        selected_toolchain = qvariant_converter.getStringDict(self.pageContent.toolchainList.currentItem().data(Qt.UserRole))
+        return selected_toolchain
 
     def _clearList(self):
         """
 
     def _clearList(self):
         """
@@ -288,4 +295,6 @@ class BToolchainPage(BWizardPage):
         Enable the remove button.
         """
         self.pageContent.removeButton.setEnabled(True)
         Enable the remove button.
         """
         self.pageContent.removeButton.setEnabled(True)
-        
\ No newline at end of file
+        
+    def currentItem(self):
+        return self.pageContent.toolchainList.currentItem()