diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 2aae1fff21..994966f9b7 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -632,7 +632,10 @@ class CuraEngineBackend(QObject, Backend): self.setState(BackendState.Done) self.processingProgress.emit(1.0) - gcode_list = self._scene.gcode_dict[self._start_slice_job_build_plate] #type: ignore #Because we generate this attribute dynamically. + try: + gcode_list = self._scene.gcode_dict[self._start_slice_job_build_plate] #type: ignore #Because we generate this attribute dynamically. + except KeyError: # Can occur if the g-code has been cleared while a slice message is still arriving from the other end. + gcode_list = [] for index, line in enumerate(gcode_list): replaced = line.replace("{print_time}", str(self._application.getPrintInformation().currentPrintTime.getDisplayString(DurationFormat.Format.ISO8601))) replaced = replaced.replace("{filament_amount}", str(self._application.getPrintInformation().materialLengths))