From 4439ce1e433fe72fb15321086b0e2481e4177679 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Mon, 2 Oct 2017 16:31:32 +0200 Subject: [PATCH 1/2] Stop building and sending the POST request if the user has already aborted it all CL-511 --- .../NetworkClusterPrinterOutputDevice.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkClusterPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkClusterPrinterOutputDevice.py index 94bd6bc9a3..c719652427 100644 --- a/plugins/UM3NetworkPrinting/NetworkClusterPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkClusterPrinterOutputDevice.py @@ -275,7 +275,10 @@ class NetworkClusterPrinterOutputDevice(NetworkPrinterOutputDevice.NetworkPrinte self._file_name = "%s.gcode.gz" % file_name self._showProgressMessage() - self._request = self._buildSendPrintJobHttpRequest(require_printer_name) + new_request = self._buildSendPrintJobHttpRequest(require_printer_name) + if new_request is None or self._stage != OutputStage.uploading: + return + self._request = new_request self._reply = self._manager.post(self._request, self._multipart) self._reply.uploadProgress.connect(self._onUploadProgress) # See _finishedPostPrintJobRequest() @@ -294,7 +297,7 @@ class NetworkClusterPrinterOutputDevice(NetworkPrinterOutputDevice.NetworkPrinte gcode = getattr(Application.getInstance().getController().getScene(), "gcode_list") compressed_gcode = self._compressGcode(gcode) if compressed_gcode is None: - return # User aborted print, so stop trying. + return None # User aborted print, so stop trying. part.setBody(compressed_gcode) self._multipart.append(part) @@ -331,7 +334,7 @@ class NetworkClusterPrinterOutputDevice(NetworkPrinterOutputDevice.NetworkPrinte for line in gcode: if not self._compressing_print: self._progress_message.hide() - return # Stop trying to zip, abort was called. + return None # Stop trying to zip, abort was called. batched_line += line # if the gcode was read from a gcode file, self._gcode will be a list of all lines in that file. # Compressing line by line in this case is extremely slow, so we need to batch them. From ece9f73a1055db401ea9d37bc41d4b70c90bea45 Mon Sep 17 00:00:00 2001 From: Simon Edwards Date: Mon, 2 Oct 2017 16:32:38 +0200 Subject: [PATCH 2/2] Don't actively none/null out the Qt network objects. Let them live longer to avoid "premature object destroy" crashes. CL-511 --- .../UM3NetworkPrinting/NetworkClusterPrinterOutputDevice.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkClusterPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkClusterPrinterOutputDevice.py index c719652427..2b69dd6a11 100644 --- a/plugins/UM3NetworkPrinting/NetworkClusterPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkClusterPrinterOutputDevice.py @@ -628,9 +628,7 @@ class NetworkClusterPrinterOutputDevice(NetworkPrinterOutputDevice.NetworkPrinte request.setRawHeader(b"User-agent", b"CuraPrintClusterOutputDevice Plugin") def _cleanupRequest(self): - self._reply = None self._request = None - self._multipart = None self._stage = OutputStage.ready self._file_name = None @@ -683,8 +681,7 @@ class NetworkClusterPrinterOutputDevice(NetworkPrinterOutputDevice.NetworkPrinte Logger.log("d", "User aborted sending print to remote.") self._progress_message.hide() self._compressing_print = False - self._stage = OutputStage.ready if self._reply: self._reply.abort() - self._reply = None + self._stage = OutputStage.ready Application.getInstance().showPrintMonitor.emit(False)