Merge pull request #6311 from Ultimaker/CS-284_fix_crash_missing_printer_configuration

Check if printerConfiguration is actually set before trying to access it
This commit is contained in:
Simon Edwards 2019-09-06 10:30:25 +02:00 committed by GitHub
commit f53031f6b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,7 +66,11 @@ class ClusterPrinterStatus(BaseModel):
## Creates a new output model.
# \param controller - The controller of the model.
def createOutputModel(self, controller: PrinterOutputController) -> PrinterOutputModel:
model = PrinterOutputModel(controller, len(self.configuration), firmware_version = self.firmware_version)
# FIXME
# Note that we're using '2' here as extruder count. We have hardcoded this for now to prevent issues where the
# amount of extruders coming back from the API is actually lower (which it can be if a printer was just added
# to a cluster). This should be fixed in the future, probably also on the cluster API side.
model = PrinterOutputModel(controller, 2, firmware_version = self.firmware_version)
self.updateOutputModel(model)
return model
@ -80,6 +84,11 @@ class ClusterPrinterStatus(BaseModel):
model.updateBuildplate(self.build_plate.type if self.build_plate else "glass")
model.setCameraUrl(QUrl("http://{}:8080/?action=stream".format(self.ip_address)))
if not model.printerConfiguration:
# Prevent accessing printer configuration when not available.
# This sometimes happens when a printer was just added to a group and Cura is connected to that group.
return
# Set the possible configurations based on whether a Material Station is present or not.
if self.material_station and self.material_station.material_slots:
self._updateAvailableConfigurations(model)