From ec5bb444c03f609c8afd1b24dc35a7fe70ab029f Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Wed, 5 Jan 2022 17:15:38 +0100 Subject: [PATCH] Don't change metadata if there is no global stack We'll miss that status update then, but the next time Cura starts it'll update the printer status anyway. Found during testing of CURA-8591. --- cura/PrinterOutput/PrinterOutputDevice.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cura/PrinterOutput/PrinterOutputDevice.py b/cura/PrinterOutput/PrinterOutputDevice.py index 675921f0b1..d3a5e252d3 100644 --- a/cura/PrinterOutput/PrinterOutputDevice.py +++ b/cura/PrinterOutput/PrinterOutputDevice.py @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Ultimaker B.V. +# Copyright (c) 2022 Ultimaker B.V. # Cura is released under the terms of the LGPLv3 or higher. from enum import IntEnum @@ -137,7 +137,11 @@ class PrinterOutputDevice(QObject, OutputDevice): """ if self.connectionState != connection_state: self._connection_state = connection_state - cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack().setMetaDataEntry("is_online", self.isConnected()) + application = cura.CuraApplication.CuraApplication.getInstance() + if application is not None: # Might happen during the closing of Cura or in a test. + global_stack = application.getGlobalContainerStack() + if global_stack is not None: + global_stack.setMetaDataEntry("is_online", self.isConnected()) self.connectionStateChanged.emit(self._id) @pyqtProperty(int, constant = True)