From a87db2d721e7779c4b6d3650aa60155e0de22ea4 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 13 Mar 2018 09:09:21 +0100 Subject: [PATCH] Always update root material even if not in QML Previously the _current_root_material_id and _current_root_material_name dictionaries were only updated if they are used anywhere in QML. This is unreliable. We're now directly connecting to the signal so that they are always updated, even when not in use by the GUI. This way we can rely on it in other places than the GUI. Contributes to issue CURA-4606. --- cura/Settings/MachineManager.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index d79130e0c3..afff8b96b3 100755 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -125,6 +125,7 @@ class MachineManager(QObject): # When the materials lookup table gets updated, it can mean that a material has its name changed, which should # be reflected on the GUI. This signal emission makes sure that it happens. self._material_manager.materialsUpdated.connect(self.rootMaterialChanged) + self.rootMaterialChanged.connect(self._onRootMaterialChanged) activeQualityGroupChanged = pyqtSignal() activeQualityChangesGroupChanged = pyqtSignal() @@ -876,23 +877,26 @@ class MachineManager(QObject): def currentExtruderPositions(self): return sorted(list(self._global_container_stack.extruders.keys())) - @pyqtProperty("QVariant", notify = rootMaterialChanged) - def currentRootMaterialId(self): - # initial filling the current_root_material_id + ## Update _current_root_material_id and _current_root_material_name when + # the current root material was changed. + def _onRootMaterialChanged(self): self._current_root_material_id = {} for position in self._global_container_stack.extruders: self._current_root_material_id[position] = self._global_container_stack.extruders[position].material.getMetaDataEntry("base_file") - return self._current_root_material_id - @pyqtProperty("QVariant", notify = rootMaterialChanged) - def currentRootMaterialName(self): - # initial filling the current_root_material_name if self._global_container_stack: self._current_root_material_name = {} for position in self._global_container_stack.extruders: if position not in self._current_root_material_name: material = self._global_container_stack.extruders[position].material self._current_root_material_name[position] = material.getName() + + @pyqtProperty("QVariant", notify = rootMaterialChanged) + def currentRootMaterialId(self): + return self._current_root_material_id + + @pyqtProperty("QVariant", notify = rootMaterialChanged) + def currentRootMaterialName(self): return self._current_root_material_name ## Return the variant names in the extruder stack(s).