From c900e27c19e990d3d4c9233989b4321367e28877 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 22 Dec 2015 08:58:04 +0100 Subject: [PATCH 1/2] Stop slicing immediately when a ToolOperation is started --- plugins/CuraEngineBackend/CuraEngineBackend.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 534a2831eb..02c29c174c 100644 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -147,6 +147,17 @@ class CuraEngineBackend(Backend): job.start() job.finished.connect(self._onStartSliceCompleted) + def _terminate(self): + if self._slicing: + self._slicing = False + self._restart = True + if self._process is not None: + Logger.log("d", "Killing engine process") + try: + self._process.terminate() + except: # terminating a process that is already terminating causes an exception, silently ignore this. + pass + def _onStartSliceCompleted(self, job): if job.getError() or job.getResult() != True: if self._message: @@ -245,6 +256,7 @@ class CuraEngineBackend(Backend): self._restart = False def _onToolOperationStarted(self, tool): + self._terminate() # Do not continue slicing once a tool has started self._enabled = False # Do not reslice when a tool is doing it's 'thing' def _onToolOperationStopped(self, tool): From 091f7448381cc64651c8ef7399948e3f3f80c7e0 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Tue, 22 Dec 2015 09:26:21 +0100 Subject: [PATCH 2/2] Reuse code --- .../CuraEngineBackend/CuraEngineBackend.py | 38 ++++++------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 02c29c174c..955d508304 100644 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -107,15 +107,7 @@ class CuraEngineBackend(Backend): return if self._slicing: - self._slicing = False - self._restart = True - if self._process is not None: - Logger.log("d", "Killing engine process") - try: - self._process.terminate() - except: # terminating a process that is already terminating causes an exception, silently ignore this. - pass - + self._terminate() if self._message: self._message.hide() @@ -148,16 +140,15 @@ class CuraEngineBackend(Backend): job.finished.connect(self._onStartSliceCompleted) def _terminate(self): - if self._slicing: - self._slicing = False - self._restart = True - if self._process is not None: - Logger.log("d", "Killing engine process") - try: - self._process.terminate() - except: # terminating a process that is already terminating causes an exception, silently ignore this. - pass - + self._slicing = False + self._restart = True + if self._process is not None: + Logger.log("d", "Killing engine process") + try: + self._process.terminate() + except: # terminating a process that is already terminating causes an exception, silently ignore this. + pass + def _onStartSliceCompleted(self, job): if job.getError() or job.getResult() != True: if self._message: @@ -277,12 +268,5 @@ class CuraEngineBackend(Backend): def _onInstanceChanged(self): - self._slicing = False - self._restart = True - if self._process is not None: - Logger.log("d", "Killing engine process") - try: - self._process.terminate() - except: # terminating a process that is already terminating causes an exception, silently ignore this. - pass + self._terminate() self.slicingCancelled.emit()