MicroPythonReplWidget: fixed the devices rescan behaviour. micropython

Sat, 03 Aug 2019 13:37:17 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 03 Aug 2019 13:37:17 +0200
branch
micropython
changeset 7120
89ee83fadec9
parent 7119
5f609e77de99
child 7122
8e67ef7975de

MicroPythonReplWidget: fixed the devices rescan behaviour.

eric6/MicroPython/MicroPythonReplWidget.py file | annotate | diff | comparison | revisions
diff -r 5f609e77de99 -r 89ee83fadec9 eric6/MicroPython/MicroPythonReplWidget.py
--- a/eric6/MicroPython/MicroPythonReplWidget.py	Sat Aug 03 12:14:37 2019 +0200
+++ b/eric6/MicroPython/MicroPythonReplWidget.py	Sat Aug 03 13:37:17 2019 +0200
@@ -246,6 +246,8 @@
         """
         Private method to populate the device type selector.
         """
+        currentDevice = self.deviceTypeComboBox.currentText()
+        
         self.deviceTypeComboBox.clear()
         self.deviceInfoLabel.clear()
         
@@ -269,7 +271,17 @@
             self.deviceInfoLabel.setText(
                 self.tr("No supported devices detected."))
         
-        self.on_deviceTypeComboBox_activated(0)
+        index = self.deviceTypeComboBox.findText(currentDevice,
+                                                 Qt.MatchExactly)
+        if index == -1:
+            # entry is no longer present
+            index = 0
+            if self.__connected:
+                # we are still connected, so disconnect
+                self.on_connectButton_clicked()
+        
+        self.on_deviceTypeComboBox_activated(index)
+        self.deviceTypeComboBox.setCurrentIndex(index)
     
     def __handlePreferencesChanged(self):
         """
@@ -466,13 +478,12 @@
         if self.__connected:
             self.__disconnectFromDevice()
             
-            self.replButton.setChecked(False)
+            if self.replButton.isChecked():
+                self.on_replButton_clicked(False)
             if self.filesButton.isChecked():
                 self.on_filesButton_clicked(False)
-                self.filesButton.setChecked(False)
             if self.chartButton.isChecked():
                 self.on_chartButton_clicked(False)
-                self.chartButton.setChecked(False)
         else:
             self.__connectToDevice()
     

eric ide

mercurial