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 self._printer_connections[serial_port] = connection
def _onPrinterConnectionStateChanged(self, serial_port): def _onPrinterConnectionStateChanged(self, serial_port):
if self._printer_connections[serial_port].connectionState == ConnectionState.CONNECTED: try:
self.getOutputDeviceManager().addOutputDevice(self._printer_connections[serial_port]) if self._printer_connections[serial_port].connectionState == ConnectionState.CONNECTED:
else: self.getOutputDeviceManager().addOutputDevice(self._printer_connections[serial_port])
self.getOutputDeviceManager().removeOutputDevice(serial_port) else:
self.printerConnectionStateChanged.emit() 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) @pyqtProperty(QObject , notify = printerConnectionStateChanged)
def connectedPrinterList(self): def connectedPrinterList(self):

View file

@ -117,7 +117,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice):
def _homeBed(self): def _homeBed(self):
self._sendCommand("G28 Z") self._sendCommand("G28 Z")
@pyqtSlot() @pyqtSlot()
def startPrint(self): def startPrint(self):
self.writeStarted.emit(self) self.writeStarted.emit(self)