From 953d59788e5b72ac8ef27bc88a65e84a4d6789e8 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 6 Apr 2017 13:57:39 +0200 Subject: [PATCH 1/2] Only try to close connection when there is a connection to close CURA-3603 --- plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index a4f05a6f75..a4aea5ecb8 100755 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -716,7 +716,8 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): ## Start requesting data from printer def connect(self): - self.close() # Ensure that previous connection (if any) is killed. + if self.isConnected(): + self.close() # Close previous connection self._createNetworkManager() From a4afde39ff473f5dcc29a88688529494af5902c2 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 6 Apr 2017 14:03:41 +0200 Subject: [PATCH 2/2] 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.