Fixed an issue in the MicroPython UF2 Flash dialog causing the wrong instructions being show in certain situations. eric7

Sat, 02 Dec 2023 12:19:16 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 02 Dec 2023 12:19:16 +0100
branch
eric7
changeset 10370
d84b074f772c
parent 10369
170795bb532d
child 10371
1f54843e8152

Fixed an issue in the MicroPython UF2 Flash dialog causing the wrong instructions being show in certain situations.

src/eric7/MicroPython/UF2FlashDialog.py file | annotate | diff | comparison | revisions
--- a/src/eric7/MicroPython/UF2FlashDialog.py	Fri Dec 01 16:55:44 2023 +0100
+++ b/src/eric7/MicroPython/UF2FlashDialog.py	Sat Dec 02 12:19:16 2023 +0100
@@ -674,7 +674,7 @@
     if not OSUtilities.isWindowsPlatform():
         userMounts = FileSystemUtilities.getUserMounts()
 
-    boardTypes = [boardType] if boardType else list(SupportedUF2Boards.keys())
+    boardTypes = [boardType] if boardType else [*SupportedUF2Boards.keys()]
     for board in boardTypes:
         for vidpid, volumes in SupportedUF2Boards[board]["volumes"].items():
             for volume, description in volumes:
@@ -715,7 +715,7 @@
                         )
                     )
 
-    return list(foundDevices)
+    return [*foundDevices]
 
 
 class UF2FlashDialog(QDialog, Ui_UF2FlashDialog):
@@ -780,19 +780,22 @@
         # now populate the entries with data
         devices = getFoundDevices(boardType=self.__boardType)
         if len(devices) == 0:
-            # no device detected
-            devices = list(
-                filter(
-                    lambda x: x[0] in SupportedUF2Boards,
-                    Devices.getFoundDevices()[0],
-                )
+            # no device set yet
+            devices = [
+                d
+                for d in Devices.getFoundDevices()[0]
+                if d[0] in SupportedUF2Boards
+            ]
+            self.devicesComboBox.addItem("")
+            self.devicesComboBox.addItem(self.tr("Manual Select"))
+            self.devicesComboBox.setItemData(
+                self.devicesComboBox.count() - 1, self.__manualType, self.DeviceTypeRole
             )
+            self.on_devicesComboBox_currentIndexChanged(0)
             if devices:
-                self.__showSpecificInstructions(list(devices))
+                self.__showSpecificInstructions(devices)
             else:
                 self.__showAllInstructions()
-            self.devicesComboBox.addItem(self.tr("Manual Select"))
-            self.devicesComboBox.setItemData(0, self.__manualType, self.DeviceTypeRole)
         elif len(devices) == 1:
             # set the board type to the found one
             self.__boardType = devices[0][0]
@@ -1132,7 +1135,7 @@
                 self.tr("""No UF2 device 'boot' volumes found."""),
             )
         elif len(foundBootVolumes) == 1:
-            selectedVolume = list(foundBootVolumes)[0]
+            selectedVolume = [*foundBootVolumes][0]
         else:
             result, ok = QInputDialog.getItem(
                 self,
@@ -1140,7 +1143,7 @@
                 QCoreApplication.translate(
                     "UF2FlashDialog", "Select the Boot Volume of the device:"
                 ),
-                list(foundBootVolumes),
+                [*foundBootVolumes],
                 0,
                 True,
             )

eric ide

mercurial