Thu, 25 Feb 2021 17:52:28 +0100
MicroPython: fixed some logic issues related to handling of unknown devices.
eric6/MicroPython/ConnectionSelectionDialog.py | file | annotate | diff | comparison | revisions | |
eric6/MicroPython/MicroPythonWidget.py | file | annotate | diff | comparison | revisions |
--- a/eric6/MicroPython/ConnectionSelectionDialog.py Wed Feb 24 20:17:35 2021 +0100 +++ b/eric6/MicroPython/ConnectionSelectionDialog.py Thu Feb 25 17:52:28 2021 +0100 @@ -50,7 +50,6 @@ index, portName, self.PortNameRole) self.portNameComboBox.setItemData( index, (vid, pid), self.VidPidRole) - self.portNameComboBox.setCurrentText(currentPort) self.deviceTypeComboBox.addItem("", "") for board, description in sorted( @@ -58,8 +57,18 @@ key=lambda x: x[1] ): self.deviceTypeComboBox.addItem(description, board) - index = self.deviceTypeComboBox.findData(currentType) - self.deviceTypeComboBox.setCurrentIndex(index) + + if self.portNameComboBox.currentText(): + # some ports were found; use the previously selected type as + # default + portIndex = self.portNameComboBox.findData( + currentPort, self.PortNameRole) + typeIndex = self.deviceTypeComboBox.findData(currentType) + else: + portIndex = 0 + typeIndex = 0 + self.portNameComboBox.setCurrentIndex(portIndex) + self.deviceTypeComboBox.setCurrentIndex(typeIndex) self.__updateOK()
--- a/eric6/MicroPython/MicroPythonWidget.py Wed Feb 24 20:17:35 2021 +0100 +++ b/eric6/MicroPython/MicroPythonWidget.py Thu Feb 25 17:52:28 2021 +0100 @@ -338,6 +338,10 @@ self.deviceInfoLabel.setText( self.tr("No supported devices detected.")) + self.__unknownPorts = unknownPorts + if self.__unknownPorts: + self.connectButton.setEnabled(True) + index = self.deviceTypeComboBox.findText(currentDevice, Qt.MatchExactly) if index == -1: @@ -397,10 +401,6 @@ yesDefault=True) if yes: self.__addUnknownDevices(list(newUnknownDevices)) - - self.__unknownPorts = unknownPorts - if self.__unknownPorts: - self.connectButton.setEnabled(True) def __handlePreferencesChanged(self): """ @@ -1024,6 +1024,8 @@ self.__lastPort = port self.__lastDeviceType = deviceType + else: + return if self.__interface.connectToDevice(port): self.__setConnected(True)