From a821346b072a7dc0115b84de7293ff5ef6a2eb6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gina=20H=C3=A4u=C3=9Fge?= Date: Wed, 4 Apr 2018 10:29:01 +0200 Subject: [PATCH] Don't trigger PRINT_FAILED twice on disconnect Fixes #2546 --- src/octoprint/printer/standard.py | 3 ++- src/octoprint/util/comm.py | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/octoprint/printer/standard.py b/src/octoprint/printer/standard.py index b85f4e501..d11e47ffc 100644 --- a/src/octoprint/printer/standard.py +++ b/src/octoprint/printer/standard.py @@ -1176,7 +1176,8 @@ class Printer(PrinterInterface, comm.MachineComPrintCallback): def on_comm_print_job_failed(self): payload = self._payload_for_print_job_event() - eventManager().fire(Events.PRINT_FAILED, payload) + if payload: + eventManager().fire(Events.PRINT_FAILED, payload) def on_comm_print_job_cancelling(self, firmware_error=None): payload = self._payload_for_print_job_event() diff --git a/src/octoprint/util/comm.py b/src/octoprint/util/comm.py index 51eb1393c..45975124a 100644 --- a/src/octoprint/util/comm.py +++ b/src/octoprint/util/comm.py @@ -850,7 +850,6 @@ class MachineCom(object): self._monitoring_active = False self._send_queue_active = False - printing = self.isPrinting() or self.isPaused() if self._serial is not None: if not is_error: self.sendGcodeScript("beforePrinterDisconnected") @@ -883,6 +882,7 @@ class MachineCom(object): self._logger.exception("Error while trying to close serial port") is_error = True + # if we are printing, this will also make sure of firing PRINT_FAILED if is_error: self._changeState(self.STATE_CLOSED_WITH_ERROR) else: @@ -894,9 +894,6 @@ class MachineCom(object): if settings().getBoolean(["feature", "sdSupport"]): self._sdFileList = [] - if printing: - self._callback.on_comm_print_job_failed() - def setTemperatureOffset(self, offsets): self._tempOffsets.update(offsets)