Fixed posponing of certain events

CURA-3780
This commit is contained in:
Jaime van Kessel 2017-05-10 13:16:49 +02:00
parent 740346e0d8
commit e313794b12
2 changed files with 10 additions and 10 deletions

View file

@ -66,8 +66,8 @@ class CuraContainerStack(ContainerStack):
## Set the quality changes container. ## Set the quality changes container.
# #
# \param new_quality_changes The new quality changes container. It is expected to have a "type" metadata entry with the value "quality_changes". # \param new_quality_changes The new quality changes container. It is expected to have a "type" metadata entry with the value "quality_changes".
def setQualityChanges(self, new_quality_changes: InstanceContainer) -> None: def setQualityChanges(self, new_quality_changes: InstanceContainer, postpone_emit = False) -> None:
self.replaceContainer(_ContainerIndexes.QualityChanges, new_quality_changes) self.replaceContainer(_ContainerIndexes.QualityChanges, new_quality_changes, postpone_emit = postpone_emit)
## Set the quality changes container by an ID. ## Set the quality changes container by an ID.
# #
@ -93,8 +93,8 @@ class CuraContainerStack(ContainerStack):
## Set the quality container. ## Set the quality container.
# #
# \param new_quality The new quality container. It is expected to have a "type" metadata entry with the value "quality". # \param new_quality The new quality container. It is expected to have a "type" metadata entry with the value "quality".
def setQuality(self, new_quality: InstanceContainer) -> None: def setQuality(self, new_quality: InstanceContainer, postpone_emit = False) -> None:
self.replaceContainer(_ContainerIndexes.Quality, new_quality) self.replaceContainer(_ContainerIndexes.Quality, new_quality, postpone_emit = postpone_emit)
## Set the quality container by an ID. ## Set the quality container by an ID.
# #
@ -131,8 +131,8 @@ class CuraContainerStack(ContainerStack):
## Set the material container. ## Set the material container.
# #
# \param new_quality_changes The new material container. It is expected to have a "type" metadata entry with the value "quality_changes". # \param new_quality_changes The new material container. It is expected to have a "type" metadata entry with the value "quality_changes".
def setMaterial(self, new_material: InstanceContainer) -> None: def setMaterial(self, new_material: InstanceContainer, postpone_emit = False) -> None:
self.replaceContainer(_ContainerIndexes.Material, new_material) self.replaceContainer(_ContainerIndexes.Material, new_material, postpone_emit = postpone_emit)
## Set the material container by an ID. ## Set the material container by an ID.
# #

View file

@ -835,8 +835,8 @@ class MachineManager(QObject):
name_changed_connect_stacks.append(stack_quality) name_changed_connect_stacks.append(stack_quality)
name_changed_connect_stacks.append(stack_quality_changes) name_changed_connect_stacks.append(stack_quality_changes)
self._replaceQualityOrQualityChangesInStack(stack, stack_quality) self._replaceQualityOrQualityChangesInStack(stack, stack_quality, postpone_emit=True)
self._replaceQualityOrQualityChangesInStack(stack, stack_quality_changes) self._replaceQualityOrQualityChangesInStack(stack, stack_quality_changes, postpone_emit=True)
# Send emits that are postponed in replaceContainer. # Send emits that are postponed in replaceContainer.
# Here the stacks are finished replacing and every value can be resolved based on the current state. # Here the stacks are finished replacing and every value can be resolved based on the current state.
@ -955,13 +955,13 @@ class MachineManager(QObject):
container_type = container.getMetaDataEntry("type") container_type = container.getMetaDataEntry("type")
if container_type == "quality": if container_type == "quality":
stack.quality.nameChanged.disconnect(self._onQualityNameChanged) stack.quality.nameChanged.disconnect(self._onQualityNameChanged)
stack.setQuality(container) stack.setQuality(container, postpone_emit = postpone_emit)
stack.qualityChanges.nameChanged.connect(self._onQualityNameChanged) stack.qualityChanges.nameChanged.connect(self._onQualityNameChanged)
elif container_type == "quality_changes" or container_type is None: elif container_type == "quality_changes" or container_type is None:
# If the container is an empty container, we need to change the quality_changes. # If the container is an empty container, we need to change the quality_changes.
# Quality can never be set to empty. # Quality can never be set to empty.
stack.qualityChanges.nameChanged.disconnect(self._onQualityNameChanged) stack.qualityChanges.nameChanged.disconnect(self._onQualityNameChanged)
stack.setQualityChanges(container) stack.setQualityChanges(container, postpone_emit = postpone_emit)
stack.qualityChanges.nameChanged.connect(self._onQualityNameChanged) stack.qualityChanges.nameChanged.connect(self._onQualityNameChanged)
self._onQualityNameChanged() self._onQualityNameChanged()