From 99d9961297923cca6e49523f96015076bc41afe5 Mon Sep 17 00:00:00 2001 From: "A.Sasin" Date: Tue, 10 Oct 2017 09:16:35 +0200 Subject: [PATCH] Cura crashed because of RuntimeError after switching between monitor and prepare view CURA-4376 --- .../UM3NetworkPrinting/NetworkPrinterOutputDevice.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py index af2e1f8c00..0b607c25f5 100755 --- a/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py +++ b/plugins/UM3NetworkPrinting/NetworkPrinterOutputDevice.py @@ -334,13 +334,17 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice): self._camera_timer.stop() if self._image_reply: + skip_abort = False try: try: self._image_reply.downloadProgress.disconnect(self._onStreamDownloadProgress) - except TypeError: - pass #The signal was never connected. - self._image_reply.abort() - except RuntimeError: + except Exception as e: + if type(e) != RuntimeError: # can happen the RuntimeError occurs before calling abort (=see below), then then the application will crash + skip_abort = True + pass #The signal was never connected. + if not skip_abort: + self._image_reply.abort() + except Exception as e: #RuntimeError pass # It can happen that the wrapped c++ object is already deleted. self._image_reply = None self._image_request = None