Remove _current_quality_group shadow administration

This was causing asynchronicities.

Contributes to issue CURA-6600.
This commit is contained in:
Ghostkeeper 2019-08-27 12:39:19 +02:00
parent 89a5fe41fe
commit 62395d5503
No known key found for this signature in database
GPG Key ID: 86BEF881AE2CF276

View File

@ -61,7 +61,6 @@ class MachineManager(QObject):
self._global_container_stack = None # type: Optional[GlobalStack] self._global_container_stack = None # type: Optional[GlobalStack]
self._current_root_material_id = {} # type: Dict[str, str] self._current_root_material_id = {} # type: Dict[str, str]
self._current_quality_group = None # type: Optional[QualityGroup]
self._current_quality_changes_group = None # type: Optional[QualityChangesGroup] self._current_quality_changes_group = None # type: Optional[QualityChangesGroup]
self._default_extruder_position = "0" # to be updated when extruders are switched on and off self._default_extruder_position = "0" # to be updated when extruders are switched on and off
@ -597,19 +596,17 @@ class MachineManager(QObject):
@pyqtProperty(bool, notify = activeQualityGroupChanged) @pyqtProperty(bool, notify = activeQualityGroupChanged)
def isActiveQualitySupported(self) -> bool: def isActiveQualitySupported(self) -> bool:
is_supported = False global_container_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
if self._global_container_stack: if not global_container_stack:
if self._current_quality_group: return False
is_supported = self._current_quality_group.is_available return self.activeQualityGroup.is_available
return is_supported
@pyqtProperty(bool, notify = activeQualityGroupChanged) @pyqtProperty(bool, notify = activeQualityGroupChanged)
def isActiveQualityExperimental(self) -> bool: def isActiveQualityExperimental(self) -> bool:
is_experimental = False global_container_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
if self._global_container_stack: if not global_container_stack:
if self._current_quality_group: return False
is_experimental = self._current_quality_group.is_experimental return Util.parseBool(global_container_stack.quality.getMetaDataEntry("is_experimental", False))
return is_experimental
## Returns whether there is anything unsupported in the current set-up. ## Returns whether there is anything unsupported in the current set-up.
# #
@ -1085,7 +1082,6 @@ class MachineManager(QObject):
def _setEmptyQuality(self) -> None: def _setEmptyQuality(self) -> None:
if self._global_container_stack is None: if self._global_container_stack is None:
return return
self._current_quality_group = None
self._current_quality_changes_group = None self._current_quality_changes_group = None
self._global_container_stack.quality = empty_quality_container self._global_container_stack.quality = empty_quality_container
self._global_container_stack.qualityChanges = empty_quality_changes_container self._global_container_stack.qualityChanges = empty_quality_changes_container
@ -1109,7 +1105,6 @@ class MachineManager(QObject):
if node.container is None: if node.container is None:
return return
self._current_quality_group = quality_group
if empty_quality_changes: if empty_quality_changes:
self._current_quality_changes_group = None self._current_quality_changes_group = None
@ -1174,7 +1169,6 @@ class MachineManager(QObject):
extruder.quality = quality_container extruder.quality = quality_container
extruder.qualityChanges = quality_changes_container extruder.qualityChanges = quality_changes_container
self._current_quality_group = quality_group
self._current_quality_changes_group = quality_changes_group self._current_quality_changes_group = quality_changes_group
self.activeQualityGroupChanged.emit() self.activeQualityGroupChanged.emit()
self.activeQualityChangesGroupChanged.emit() self.activeQualityChangesGroupChanged.emit()
@ -1515,7 +1509,10 @@ class MachineManager(QObject):
@pyqtProperty(QObject, fset = setQualityGroup, notify = activeQualityGroupChanged) @pyqtProperty(QObject, fset = setQualityGroup, notify = activeQualityGroupChanged)
def activeQualityGroup(self) -> Optional["QualityGroup"]: def activeQualityGroup(self) -> Optional["QualityGroup"]:
return self._current_quality_group global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
if global_stack.quality == empty_quality_container:
return None
return ContainerTree.getInstance().getCurrentQualityGroups().get(self.activeQualityType)
@pyqtSlot(QObject) @pyqtSlot(QObject)
def setQualityChangesGroup(self, quality_changes_group: "QualityChangesGroup", no_dialog: bool = False) -> None: def setQualityChangesGroup(self, quality_changes_group: "QualityChangesGroup", no_dialog: bool = False) -> None:
@ -1532,7 +1529,7 @@ class MachineManager(QObject):
if self._global_container_stack is None: if self._global_container_stack is None:
return return
with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue): with postponeSignals(*self._getContainerChangedSignals(), compress = CompressTechnique.CompressPerParameterValue):
self._setQualityGroup(self._current_quality_group) self._setQualityGroup(self.activeQualityGroup)
for stack in [self._global_container_stack] + list(self._global_container_stack.extruders.values()): for stack in [self._global_container_stack] + list(self._global_container_stack.extruders.values()):
stack.userChanges.clear() stack.userChanges.clear()
@ -1555,7 +1552,8 @@ class MachineManager(QObject):
@pyqtProperty(bool, notify = activeQualityGroupChanged) @pyqtProperty(bool, notify = activeQualityGroupChanged)
def hasNotSupportedQuality(self) -> bool: def hasNotSupportedQuality(self) -> bool:
return self._current_quality_group is None and self._current_quality_changes_group is None global_container_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
return global_container_stack and global_container_stack.quality == empty_quality_container and global_container_stack.qualityChanges == empty_quality_changes_container
def _updateUponMaterialMetadataChange(self) -> None: def _updateUponMaterialMetadataChange(self) -> None:
if self._global_container_stack is None: if self._global_container_stack is None: