Browse Source

Don't emit devices changed signal if remove wasn't successful

The same could be done for adding but let's keep it at this for now.

Hopefully fixes #2238.
Ghostkeeper 7 years ago
parent
commit
3951239513
1 changed files with 4 additions and 2 deletions
  1. 4 2
      plugins/USBPrinting/USBPrinterOutputDeviceManager.py

+ 4 - 2
plugins/USBPrinting/USBPrinterOutputDeviceManager.py

@@ -230,12 +230,14 @@ class USBPrinterOutputDeviceManager(QObject, OutputDevicePlugin, Extension):
 
     ##  If one of the states of the connected devices change, we might need to add / remove them from the global list.
     def _onConnectionStateChanged(self, serial_port):
+        success = True
         try:
             if self._usb_output_devices[serial_port].connectionState == ConnectionState.connected:
                 self.getOutputDeviceManager().addOutputDevice(self._usb_output_devices[serial_port])
             else:
-                self.getOutputDeviceManager().removeOutputDevice(serial_port)
-            self.connectionStateChanged.emit()
+                success = success and self.getOutputDeviceManager().removeOutputDevice(serial_port)
+            if success:
+                self.connectionStateChanged.emit()
         except KeyError:
             Logger.log("w", "Connection state of %s changed, but it was not found in the list")