From: daid303 Date: Tue, 9 Apr 2013 16:51:00 +0000 (+0200) Subject: Properly clean up the temp files from slicing. X-Git-Tag: 13.05~116 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=6fd24767b346bae78b3f91ea0e91adc9800a1158;p=cura.git Properly clean up the temp files from slicing. --- 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):