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.
This commit is contained in:
Ghostkeeper 2017-08-31 13:24:24 +02:00
parent 37eb74e99e
commit 3951239513
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

@ -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")