From 9b031ff9d32b8a0b866ede00353653ff48e61eff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Mon, 3 Mar 2014 15:25:42 +0100 Subject: [PATCH] Hopefully fixed a race condition that could occur when pressing "Print" (file not opened yet, but comm layer tries to fetch next command) --- src/octoprint/util/comm.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 3eba14ac..29a08b31 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -381,17 +381,17 @@ class MachineCom(object): if self._currentFile is None: raise ValueError("No file selected for printing") - wasPaused = self.isPaused() - self._printSection = "CUSTOM" - self._changeState(self.STATE_PRINTING) - eventManager().fire(Events.PRINT_STARTED, { - "file": self._currentFile.getFilename(), - "filename": os.path.basename(self._currentFile.getFilename()), - "origin": self._currentFile.getFileLocation() - }) - try: self._currentFile.start() + + wasPaused = self.isPaused() + self._changeState(self.STATE_PRINTING) + eventManager().fire(Events.PRINT_STARTED, { + "file": self._currentFile.getFilename(), + "filename": os.path.basename(self._currentFile.getFilename()), + "origin": self._currentFile.getFileLocation() + }) + if self.isSdFileSelected(): if wasPaused: self.sendCommand("M26 S0") @@ -677,7 +677,6 @@ class MachineCom(object): }) elif 'Writing to file' in line: # anwer to M28, at least on Marlin, Repetier and Sprinter: "Writing to file: %s" - self._printSection = "CUSTOM" self._changeState(self.STATE_PRINTING) line = "ok" elif 'Done printing file' in line: @@ -1258,6 +1257,9 @@ class PrintingGcodeFileInformation(PrintingFileInformation): def __init__(self, filename, offsetCallback): PrintingFileInformation.__init__(self, filename) + + self._filehandle = None + self._filesetMenuModehandle = None self._lineCount = None self._firstLine = None