Add try/finally for every setOverrideCursor/restoreOverrideCursor.
authorduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 30 Mar 2010 15:02:45 +0000 (15:02 +0000)
committerduplo <duplo@38d2e660-2303-0410-9eaa-f027e97ec537>
Tue, 30 Mar 2010 15:02:45 +0000 (15:02 +0000)
git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3334 38d2e660-2303-0410-9eaa-f027e97ec537

wizard/BCpuPage.py
wizard/BEditingDialog.py
wizard/BFinalPage.py
wizard/BModulePage.py
wizard/BToolchainPage.py

index 085b06e75093763130fc1d38c81f8209ddea2d0b..e9052e6773736e5ba57d2575c2cb637223de7f03 100644 (file)
@@ -107,18 +107,20 @@ class BCpuPage(BWizardPage):
         """
         Overload of the BWizardPage reloadData method.
         """
-        QApplication.instance().setOverrideCursor(Qt.WaitCursor)
-        self.project().loadSourceTree()
-        self.populateCpuList()
-        cpu_name = self.projectInfo("CPU_NAME")
-        selected_freq = self.projectInfo("SELECTED_FREQ")
-        self.setupUi()
-        if cpu_name:
-            self.selectItem(cpu_name)
-            if selected_freq:
-                self.setFrequency(selected_freq)
-                self.freq_modified = True
-        QApplication.instance().restoreOverrideCursor()
+        try:
+            QApplication.instance().setOverrideCursor(Qt.WaitCursor)
+            self.project().loadSourceTree()
+            self.populateCpuList()
+            cpu_name = self.projectInfo("CPU_NAME")
+            selected_freq = self.projectInfo("SELECTED_FREQ")
+            self.setupUi()
+            if cpu_name:
+                self.selectItem(cpu_name)
+                if selected_freq:
+                    self.setFrequency(selected_freq)
+                    self.freq_modified = True
+        finally:
+            QApplication.instance().restoreOverrideCursor()
         self.emit(SIGNAL("completeChanged()"))
 
     ####
index 825fb1c67dbc4b0ae7a7912b5b7c819ae4a42af2..cc8a80aa38a9d33d2201203432d20a51e5274aa5 100644 (file)
@@ -125,33 +125,37 @@ class BEditingDialog(QDialog):
                 self.tr("Changing the BeRTOS version will destroy all the modification done on the BeRTOS sources"),
                 QMessageBox.Ok | QMessageBox.Cancel
             ) == QMessageBox.Ok:
-                qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
-                dialog.version_page.setProjectInfo("SOURCES_PATH", version)
-                dialog.version_page.setProjectInfo("OLD_SOURCES_PATH", current_version)
-                enabled_modules = bertos_utils.enabledModules(dialog.version_page.project())
-                old_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
-                dialog.version_page.project().loadSourceTree()
-                bertos_utils.loadModuleData(dialog.version_page.project())
-                new_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
-                merged_configuration = {}
-                for conf in new_configuration:
-                    if conf in old_configuration:
-                        configuration = bertos_utils.updateConfigurationValues(new_configuration[conf], old_configuration[conf])
-                    else:
-                        configuration = new_configuration[conf]
-                    merged_configuration[conf] = configuration
-                dialog.version_page.setProjectInfo("CONFIGURATIONS", merged_configuration)
-                bertos_utils.setEnabledModules(dialog.version_page.project(), enabled_modules)
-                self.module_page.fillModuleTree()
-                qApp.restoreOverrideCursor()
+                try:
+                    qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
+                    dialog.version_page.setProjectInfo("SOURCES_PATH", version)
+                    dialog.version_page.setProjectInfo("OLD_SOURCES_PATH", current_version)
+                    enabled_modules = bertos_utils.enabledModules(dialog.version_page.project())
+                    old_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
+                    dialog.version_page.project().loadSourceTree()
+                    bertos_utils.loadModuleData(dialog.version_page.project())
+                    new_configuration = dialog.version_page.projectInfo("CONFIGURATIONS")
+                    merged_configuration = {}
+                    for conf in new_configuration:
+                        if conf in old_configuration:
+                            configuration = bertos_utils.updateConfigurationValues(new_configuration[conf], old_configuration[conf])
+                        else:
+                            configuration = new_configuration[conf]
+                        merged_configuration[conf] = configuration
+                    dialog.version_page.setProjectInfo("CONFIGURATIONS", merged_configuration)
+                    bertos_utils.setEnabledModules(dialog.version_page.project(), enabled_modules)
+                    self.module_page.fillModuleTree()
+                finally:
+                    qApp.restoreOverrideCursor()
             else:
                 # Rollback version to the previous selected one.
                 dialog.version_page.setProjectInfo("SOURCES_PATH", current_version)
 
     def apply(self):
-        qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
-        createBertosProject(self.module_page.project(), edit=True)
-        qApp.restoreOverrideCursor()
+        try:
+            qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
+            createBertosProject(self.module_page.project(), edit=True)
+        finally:
+            qApp.restoreOverrideCursor()
         self.accept()
 
     def toolchains(self):
index 3f1a9e02d6359dbe0d91a26abc6872702106084a..f5d353edfd4e200f90c6bc84afb3028860a35281 100644 (file)
@@ -57,9 +57,11 @@ class BFinalPage(BWizardPage):
         """
         Overload of the BWizardPage reloadData method.
         """
-        QApplication.instance().setOverrideCursor(Qt.WaitCursor)
-        bertos_utils.createBertosProject(self.project())
-        QApplication.instance().restoreOverrideCursor()
+        try:
+            QApplication.instance().setOverrideCursor(Qt.WaitCursor)
+            bertos_utils.createBertosProject(self.project())
+        finally:
+            QApplication.instance().restoreOverrideCursor()
         self._plugin_dict = {}
         if os.name == "nt":
             output = self.projectInfo("OUTPUT")
index 4eb9a55e03da22c8a58af9e37e1fc3d571bed1d3..3d7fa2fc39634602d47b9ff423d537ec6feac20b 100644 (file)
@@ -86,11 +86,13 @@ class BModulePage(BWizardPage):
         """
         Overload of the BWizardPage reloadData method.
         """
-        QApplication.instance().setOverrideCursor(Qt.WaitCursor)
-        self.setupUi()
-        self.loadModuleData()
-        self.fillModuleTree()
-        QApplication.instance().restoreOverrideCursor()
+        try:
+            QApplication.instance().setOverrideCursor(Qt.WaitCursor)
+            self.setupUi()
+            self.loadModuleData()
+            self.fillModuleTree()
+        finally:
+            QApplication.instance().restoreOverrideCursor()
     
     ####
     
@@ -402,70 +404,74 @@ class BModulePage(BWizardPage):
         """
         Resolves the selection dependencies.
         """
-        qApp.setOverrideCursor(Qt.WaitCursor)
-        modules = self.projectInfo("MODULES")
-        modules[selectedModule]["enabled"] = True
-        self.setProjectInfo("MODULES", modules)
-        depends = self.projectInfo("MODULES")[selectedModule]["depends"]
-        unsatisfied = []
-        if self.pageContent.automaticFix.isChecked():
-            unsatisfied = self.selectDependencyCheck(selectedModule)
-        if len(unsatisfied) > 0:
-            for module in unsatisfied:
-                modules = self.projectInfo("MODULES")
-                modules[module]["enabled"] = True
-            for category in range(self.pageContent.moduleTree.topLevelItemCount()):
-                item = self.pageContent.moduleTree.topLevelItem(category)
-                for child in range(item.childCount()):
-                    if unicode(item.child(child).text(0)) in unsatisfied:
-                        self.setBold(item.child(child), True)
-                        self.setBold(item, True)
-                        item.child(child).setCheckState(0, Qt.Checked)
-        qApp.restoreOverrideCursor()
-    
-    def moduleUnselected(self, unselectedModule):
-        """
-        Resolves the unselection dependencies.
-        """
-        qApp.setOverrideCursor(Qt.WaitCursor)
-        modules = self.projectInfo("MODULES")
-        modules[unselectedModule]["enabled"] = False
-        self.setProjectInfo("MODULES", modules)
-        unsatisfied = []
-        unsatisfied_params = []
-        if self.pageContent.automaticFix.isChecked():
-            unsatisfied, unsatisfied_params = self.unselectDependencyCheck(unselectedModule)
-        if len(unsatisfied) > 0 or len(unsatisfied_params) > 0:
-            message = []
-            heading = self.tr("The module %1 is needed by").arg(unselectedModule)
-            message.append(heading)
-            module_list = ", ".join(unsatisfied)
-            param_list = ", ".join(["%s (%s)" %(param_name, module) for module, param_name in unsatisfied_params])
-            if module_list:
-                message.append(QString(module_list))
-            if module_list and param_list:
-                message.append(self.tr("and by"))
-            if param_list:
-                message.append(QString(param_list))
-            message_str = QStringList(message).join(" ")
-            message_str.append(self.tr("\n\nDo you want to automatically fix these conflicts?"))
-            qApp.restoreOverrideCursor()
-            choice = QMessageBox.warning(self, self.tr("Dependency error"), message_str, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
+        try:
             qApp.setOverrideCursor(Qt.WaitCursor)
-            if choice == QMessageBox.Yes:
+            modules = self.projectInfo("MODULES")
+            modules[selectedModule]["enabled"] = True
+            self.setProjectInfo("MODULES", modules)
+            depends = self.projectInfo("MODULES")[selectedModule]["depends"]
+            unsatisfied = []
+            if self.pageContent.automaticFix.isChecked():
+                unsatisfied = self.selectDependencyCheck(selectedModule)
+            if len(unsatisfied) > 0:
                 for module in unsatisfied:
                     modules = self.projectInfo("MODULES")
-                    modules[module]["enabled"] = False
+                    modules[module]["enabled"] = True
                 for category in range(self.pageContent.moduleTree.topLevelItemCount()):
                     item = self.pageContent.moduleTree.topLevelItem(category)
                     for child in range(item.childCount()):
                         if unicode(item.child(child).text(0)) in unsatisfied:
-                            item.child(child).setCheckState(0, Qt.Unchecked)
-                for module, param in unsatisfied_params:
-                    configuration_file = self.projectInfo("MODULES")[module]["configuration"]
-                    configurations = self.projectInfo("CONFIGURATIONS")
-                    configurations[configuration_file][param]["value"] = "0"
-                    self.setProjectInfo("CONFIGURATIONS", configurations)
+                            self.setBold(item.child(child), True)
+                            self.setBold(item, True)
+                            item.child(child).setCheckState(0, Qt.Checked)
+        finally:
+            qApp.restoreOverrideCursor()
+    
+    def moduleUnselected(self, unselectedModule):
+        """
+        Resolves the unselection dependencies.
+        """
+        try:
+            qApp.setOverrideCursor(Qt.WaitCursor)
+            modules = self.projectInfo("MODULES")
+            modules[unselectedModule]["enabled"] = False
+            self.setProjectInfo("MODULES", modules)
+            unsatisfied = []
+            unsatisfied_params = []
+            if self.pageContent.automaticFix.isChecked():
+                unsatisfied, unsatisfied_params = self.unselectDependencyCheck(unselectedModule)
+            if len(unsatisfied) > 0 or len(unsatisfied_params) > 0:
+                message = []
+                heading = self.tr("The module %1 is needed by").arg(unselectedModule)
+                message.append(heading)
+                module_list = ", ".join(unsatisfied)
+                param_list = ", ".join(["%s (%s)" %(param_name, module) for module, param_name in unsatisfied_params])
+                if module_list:
+                    message.append(QString(module_list))
+                if module_list and param_list:
+                    message.append(self.tr("and by"))
+                if param_list:
+                    message.append(QString(param_list))
+                message_str = QStringList(message).join(" ")
+                message_str.append(self.tr("\n\nDo you want to automatically fix these conflicts?"))
+                qApp.restoreOverrideCursor()
+                choice = QMessageBox.warning(self, self.tr("Dependency error"), message_str, QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
+                qApp.setOverrideCursor(Qt.WaitCursor)
+                if choice == QMessageBox.Yes:
+                    for module in unsatisfied:
+                        modules = self.projectInfo("MODULES")
+                        modules[module]["enabled"] = False
+                    for category in range(self.pageContent.moduleTree.topLevelItemCount()):
+                        item = self.pageContent.moduleTree.topLevelItem(category)
+                        for child in range(item.childCount()):
+                            if unicode(item.child(child).text(0)) in unsatisfied:
+                                item.child(child).setCheckState(0, Qt.Unchecked)
+                    for module, param in unsatisfied_params:
+                        configuration_file = self.projectInfo("MODULES")[module]["configuration"]
+                        configurations = self.projectInfo("CONFIGURATIONS")
+                        configurations[configuration_file][param]["value"] = "0"
+                        self.setProjectInfo("CONFIGURATIONS", configurations)
+        finally:
             qApp.restoreOverrideCursor()
     
     def selectDependencyCheck(self, module):
index 6239a1d9dd0f1fa9503185b2428a272dde643452..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.
         """
-        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()
 
     ####