From a35d4ae400855895a407038d2217e2a29a9b30b2 Mon Sep 17 00:00:00 2001 From: Aleksei S Date: Mon, 5 Mar 2018 16:43:58 +0100 Subject: [PATCH] Fix: After clicking "cancel" button while sending a print job the connection is disconnected CURA-4960 --- cura/PrinterOutput/NetworkedPrinterOutputDevice.py | 3 +++ plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py index a7b7edc636..315b195e2a 100644 --- a/cura/PrinterOutput/NetworkedPrinterOutputDevice.py +++ b/cura/PrinterOutput/NetworkedPrinterOutputDevice.py @@ -219,6 +219,9 @@ class NetworkedPrinterOutputDevice(PrinterOutputDevice): reply.uploadProgress.connect(onProgress) self._registerOnFinishedCallback(reply, onFinished) + + return reply + def postForm(self, target: str, header_data: str, body_data: bytes, onFinished: Optional[Callable[[Any, QNetworkReply], None]], onProgress: Callable = None) -> None: post_part = QHttpPart() post_part.setHeader(QNetworkRequest.ContentDispositionHeader, header_data) diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index fa9abb8d4e..c0d538bb78 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -77,6 +77,9 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self._cluster_size = int(properties.get(b"cluster_size", 0)) + self._latest_reply_handler = None + + def requestWrite(self, nodes, file_name=None, filter_by_machine=False, file_handler=None, **kwargs): self.writeStarted.emit(self) @@ -147,7 +150,7 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): parts.append(self._createFormPart("name=\"file\"; filename=\"%s\"" % file_name, compressed_gcode)) - self.postFormWithParts("print_jobs/", parts, onFinished=self._onPostPrintJobFinished, onProgress=self._onUploadPrintJobProgress) + self._latest_reply_handler = self.postFormWithParts("print_jobs/", parts, onFinished=self._onPostPrintJobFinished, onProgress=self._onUploadPrintJobProgress) @pyqtProperty(QObject, notify=activePrinterChanged) def activePrinter(self) -> Optional["PrinterOutputModel"]: @@ -187,6 +190,12 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): self._sending_gcode = False Application.getInstance().getController().setActiveStage("PrepareStage") + # After compressing the sliced model Cura sends data to printer, to stop receiving updates from the request + # the "reply" should be disconnected + if self._latest_reply_handler: + self._latest_reply_handler.disconnect() + + @pyqtSlot() def openPrintJobControlPanel(self): Logger.log("d", "Opening print job control panel...")