Fix the bug related to the change version dialog refactoring
[bertos.git] / wizard / BEditingDialog.py
index 2f07643085a855fd30dfc42f2da1d85a14e087e5..3a045d194376a311ec42d00666b33b1ab1b1233e 100644 (file)
@@ -112,27 +112,28 @@ class BEditingDialog(QDialog):
         dialog = BToolchainDialog()
         if dialog.exec_():
             toolchain = qvariant_converter.getStringDict(dialog.toolchain_page.currentItem().data(Qt.UserRole))
-            toolchain_page.setProjectInfo("TOOLCHAIN", toolchain)
+            dialog.toolchain_page.setProjectInfo("TOOLCHAIN", toolchain)
     
     def changeBertosVersion(self):
+       current_version = self.module_page.projectInfo("SOURCES_PATH")
         dialog = BVersionDialog()
         if dialog.exec_():
-            version = qvariant_converter.getString(version_page.currentItem().data(Qt.UserRole))
+            version = qvariant_converter.getString(dialog.version_page.currentItem().data(Qt.UserRole))
             if version != current_version:
                 if QMessageBox.question(
-                    version_page,
+                    dialog.version_page,
                     self.tr("BeRTOS version update"),
                     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))
-                    version_page.setProjectInfo("SOURCES_PATH", version)
-                    version_page.setProjectInfo("OLD_SOURCES_PATH", current_version)
-                    enabled_modules = bertos_utils.enabledModules(version_page.project())
-                    old_configuration = version_page.projectInfo("CONFIGURATIONS")
-                    bertos_utils.loadSourceTree(version_page.project())
-                    bertos_utils.loadModuleData(version_page.project())
-                    new_configuration = version_page.projectInfo("CONFIGURATIONS")
+                    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")
+                    bertos_utils.loadSourceTree(dialog.version_page.project())
+                    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:
@@ -140,13 +141,13 @@ class BEditingDialog(QDialog):
                         else:
                             configuration = new_configuration[conf]
                         merged_configuration[conf] = configuration
-                    version_page.setProjectInfo("CONFIGURATIONS", merged_configuration)
-                    bertos_utils.setEnabledModules(version_page.project(), enabled_modules)
+                    dialog.version_page.setProjectInfo("CONFIGURATIONS", merged_configuration)
+                    bertos_utils.setEnabledModules(dialog.version_page.project(), enabled_modules)
                     self.module_page.fillModuleTree()
                     qApp.restoreOverrideCursor()
                else:
                    # Rollback version to the previous selected one.
-                   version_page.setProjectInfo("SOURCES_PATH", current_version)
+                   dialog.version_page.setProjectInfo("SOURCES_PATH", current_version)
 
     def apply(self):
         qApp.setOverrideCursor(QCursor(Qt.WaitCursor))
@@ -183,10 +184,11 @@ class BToolchainDialog(QDialog):
        # TODO: to be moved in BToolchainPage
        for toolchain_row in range(toolchain_page.pageContent.toolchainList.count()):
             toolchain = qvariant_converter.getStringDict(toolchain_page.pageContent.toolchainList.item(toolchain_row).data(Qt.UserRole))
-           if toolchain["path"] == current_toolchain["path"]:
+           if current_toolchain and toolchain["path"] == current_toolchain["path"]:
                 toolchain_page.pageContent.toolchainList.setCurrentRow(toolchain_row)
                toolchain_page.selectionChanged()
                break
+       self.toolchain_page = toolchain_page
         layout.addWidget(toolchain_page)
         button_layout = QHBoxLayout()
         button_layout.addStretch()
@@ -207,6 +209,7 @@ class BVersionDialog(QDialog):
         layout = QVBoxLayout()
         version_page = BVersionPage()
         version_page.reloadData()
+       self.version_page = version_page
         layout.addWidget(version_page)
         button_layout = QHBoxLayout()
         button_layout.addStretch()