Fix updating materials models when materials change before first printer switch

Otherwise the _extruder_stack field would not yet be set.

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-08-27 15:33:39 +02:00
parent 8346e465f6
commit 63ae6ee9ec
No known key found for this signature in database
GPG key ID: 86BEF881AE2CF276

View file

@ -31,8 +31,13 @@ class BaseMaterialsModel(ListModel):
self._container_registry = self._application.getInstance().getContainerRegistry()
self._machine_manager = self._application.getMachineManager()
self._extruder_position = 0
self._extruder_stack = None
self._enabled = True
# Update the stack and the model data when the machine changes
self._machine_manager.globalContainerChanged.connect(self._updateExtruderStack)
self._updateExtruderStack()
# Update this model when switching machines, when adding materials or changing their metadata.
self._machine_manager.activeStackChanged.connect(self._update)
@ -55,12 +60,8 @@ class BaseMaterialsModel(ListModel):
self.addRoleName(Qt.UserRole + 15, "container_node")
self.addRoleName(Qt.UserRole + 16, "is_favorite")
self._extruder_position = 0
self._extruder_stack = None
self._available_materials = None # type: Optional[Dict[str, MaterialNode]]
self._favorite_ids = set() # type: Set[str]
self._enabled = True
def _updateExtruderStack(self):
global_stack = self._machine_manager.activeMachine