mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 11:17:49 -06:00
Handle connecting & disconnecting a bit more elegant
CURA-3603
This commit is contained in:
parent
953d59788e
commit
a4afde39ff
1 changed files with 5 additions and 3 deletions
|
@ -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"):
|
||||||
Logger.log("d", "Connecting [%s]..." % key)
|
if not self._printers[key].isConnected():
|
||||||
self._printers[key].connect()
|
Logger.log("d", "Connecting [%s]..." % key)
|
||||||
self._printers[key].connectionStateChanged.connect(self._onPrinterConnectionStateChanged)
|
self._printers[key].connect()
|
||||||
|
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.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue