mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-09 07:56:22 -06:00
Refactor camera request fix
CURA-4376 - Simplify the exception handling - Use isFinished() to check the state of the network request
This commit is contained in:
parent
d11b229118
commit
57b1cb3bc8
1 changed files with 6 additions and 7 deletions
|
@ -332,16 +332,15 @@ class NetworkPrinterOutputDevice(PrinterOutputDevice):
|
||||||
self._camera_timer.stop()
|
self._camera_timer.stop()
|
||||||
|
|
||||||
if self._image_reply:
|
if self._image_reply:
|
||||||
skip_abort = False
|
|
||||||
try:
|
try:
|
||||||
|
# disconnect the signal
|
||||||
try:
|
try:
|
||||||
self._image_reply.downloadProgress.disconnect(self._onStreamDownloadProgress)
|
self._image_reply.downloadProgress.disconnect(self._onStreamDownloadProgress)
|
||||||
except Exception as e:
|
except Exception:
|
||||||
if type(e) != RuntimeError: # can happen the RuntimeError occurs before calling abort (=see below), then then the application will crash
|
pass
|
||||||
skip_abort = True
|
# abort the request if it's not finished
|
||||||
pass #The signal was never connected.
|
if not self._image_reply.isFinished():
|
||||||
if not skip_abort:
|
self._image_reply.close()
|
||||||
self._image_reply.abort()
|
|
||||||
except Exception as e: #RuntimeError
|
except Exception as e: #RuntimeError
|
||||||
pass # It can happen that the wrapped c++ object is already deleted.
|
pass # It can happen that the wrapped c++ object is already deleted.
|
||||||
self._image_reply = None
|
self._image_reply = None
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue