Attempt to fix WindowsError related bug.
[bertos.git] / wizard / BFinalPage.py
index 3f1a9e02d6359dbe0d91a26abc6872702106084a..1285850aea9bb2fb66a2b6573ecfae403316832b 100644 (file)
@@ -57,9 +57,18 @@ 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)
+            try:
+                # This operation can throw WindowsError, if the directory is
+                # locked.
+                self.project.createBertosProject()
+            except OSError, e:
+                QMessageBox.critical(self, self.tr("Error removing destination directory"), self.tr("Close all the application using this directory and retry."))
+                self.wizard().back()
+                return
+        finally:
+            QApplication.instance().restoreOverrideCursor()
         self._plugin_dict = {}
         if os.name == "nt":
             output = self.projectInfo("OUTPUT")