Prevent crash on setConnectionState when no global stack is set

This commit is contained in:
Jaime van Kessel 2022-03-30 09:46:17 +02:00
parent 994f110aed
commit 42b97d0d73

View File

@ -137,7 +137,9 @@ class PrinterOutputDevice(QObject, OutputDevice):
""" """
if self.connectionState != connection_state: if self.connectionState != connection_state:
self._connection_state = connection_state self._connection_state = connection_state
cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack().setMetaDataEntry("is_online", self.isConnected()) global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
if global_stack:
global_stack.setMetaDataEntry("is_online", self.isConnected())
self.connectionStateChanged.emit(self._id) self.connectionStateChanged.emit(self._id)
@pyqtProperty(int, constant = True) @pyqtProperty(int, constant = True)