Merge branch 'master' of github.com:Ultimaker/Cura

This commit is contained in:
Jack Ha 2017-04-06 14:08:00 +02:00
commit cebe52b1fe
2 changed files with 7 additions and 4 deletions

View file

@ -716,7 +716,8 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
## Start requesting data from printer ## Start requesting data from printer
def connect(self): def connect(self):
self.close() # Ensure that previous connection (if any) is killed. if self.isConnected():
self.close() # Close previous connection
self._createNetworkManager() self._createNetworkManager()

View file

@ -157,12 +157,14 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin):
for key in self._printers: for key in self._printers:
if key == active_machine.getMetaDataEntry("um_network_key"): if key == active_machine.getMetaDataEntry("um_network_key"):
if not self._printers[key].isConnected():
Logger.log("d", "Connecting [%s]..." % key) Logger.log("d", "Connecting [%s]..." % key)
self._printers[key].connect() self._printers[key].connect()
self._printers[key].connectionStateChanged.connect(self._onPrinterConnectionStateChanged) self._printers[key].connectionStateChanged.connect(self._onPrinterConnectionStateChanged)
else: else:
if self._printers[key].isConnected(): if self._printers[key].isConnected():
Logger.log("d", "Closing connection [%s]..." % key) Logger.log("d", "Closing connection [%s]..." % key)
self._printers[key].connectionStateChanged.disconnect(self._onPrinterConnectionStateChanged)
self._printers[key].close() self._printers[key].close()
## Because the model needs to be created in the same thread as the QMLEngine, we use a signal. ## Because the model needs to be created in the same thread as the QMLEngine, we use a signal.