From a4afde39ff473f5dcc29a88688529494af5902c2 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 6 Apr 2017 14:03:41 +0200 Subject: [PATCH] Handle connecting & disconnecting a bit more elegant CURA-3603 --- .../NetworkPrinterOutputDevicePlugin.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py index 57d176d9f0..f39d921fff 100644 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevicePlugin.py @@ -157,12 +157,14 @@ class NetworkPrinterOutputDevicePlugin(OutputDevicePlugin): for key in self._printers: if key == active_machine.getMetaDataEntry("um_network_key"): - Logger.log("d", "Connecting [%s]..." % key) - self._printers[key].connect() - self._printers[key].connectionStateChanged.connect(self._onPrinterConnectionStateChanged) + if not self._printers[key].isConnected(): + Logger.log("d", "Connecting [%s]..." % key) + self._printers[key].connect() + self._printers[key].connectionStateChanged.connect(self._onPrinterConnectionStateChanged) else: if self._printers[key].isConnected(): Logger.log("d", "Closing connection [%s]..." % key) + self._printers[key].connectionStateChanged.disconnect(self._onPrinterConnectionStateChanged) self._printers[key].close() ## Because the model needs to be created in the same thread as the QMLEngine, we use a signal.