From 6fd24767b346bae78b3f91ea0e91adc9800a1158 Mon Sep 17 00:00:00 2001 From: daid303 Date: Tue, 9 Apr 2013 18:51:00 +0200 Subject: [PATCH] Properly clean up the temp files from slicing. --- Cura/gui/mainWindow.py | 1 + Cura/util/sliceEngine.py | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py index 8216af47..36102017 100644 --- a/Cura/gui/mainWindow.py +++ b/Cura/gui/mainWindow.py @@ -423,6 +423,7 @@ class mainWindow(wx.Frame): #HACK: Set the paint function of the glCanvas to nothing so it won't keep refreshing. Which keeps wxWidgets from quiting. print "Closing down" self.scene.OnPaint = lambda e : e + self.scene._slicer.cleanup() self.Destroy() def OnQuit(self, e): diff --git a/Cura/util/sliceEngine.py b/Cura/util/sliceEngine.py index 2fa333e3..4866b4ec 100644 --- a/Cura/util/sliceEngine.py +++ b/Cura/util/sliceEngine.py @@ -32,6 +32,11 @@ class Slicer(object): self._progressSteps = ['inset', 'skin', 'export'] self._objCount = 0 + def cleanup(self): + self.abortSlicer() + os.remove(self._binaryStorageFilename) + os.remove(self._exportFilename) + def abortSlicer(self): if self._process is not None: self._process.terminate() @@ -90,7 +95,10 @@ class Slicer(object): progressValue /= self._objCount progressValue += 1.0 / self._objCount * objectNr - self._callback(progressValue, False) + try: + self._callback(progressValue, False) + except: + pass else: print '#', line.strip() line = self._process.stdout.readline() @@ -98,10 +106,13 @@ class Slicer(object): print line.strip() returnCode = self._process.wait() print returnCode - if returnCode == 0: - self._callback(1.0, True) - else: - self._callback(0.0, False) + try: + if returnCode == 0: + self._callback(1.0, True) + else: + self._callback(0.0, False) + except: + pass self._process = None def _engineSettings(self): -- 2.30.2