Added handling for when connection was never correctly added to list

CURA-1339
This commit is contained in:
Jaime van Kessel 2016-04-14 11:06:11 +02:00
parent 4f3489233c
commit 58b216828a
2 changed files with 10 additions and 6 deletions

View file

@ -197,11 +197,15 @@ class USBPrinterManager(QObject, SignalEmitter, OutputDevicePlugin, Extension):
self._printer_connections[serial_port] = connection
def _onPrinterConnectionStateChanged(self, serial_port):
try:
if self._printer_connections[serial_port].connectionState == ConnectionState.CONNECTED:
self.getOutputDeviceManager().addOutputDevice(self._printer_connections[serial_port])
else:
self.getOutputDeviceManager().removeOutputDevice(serial_port)
self.printerConnectionStateChanged.emit()
except KeyError:
pass # no output device by this device_id found in connection list.
@pyqtProperty(QObject , notify = printerConnectionStateChanged)
def connectedPrinterList(self):