Browse Source

Fixed posponing of certain events

CURA-3780
Jaime van Kessel 7 years ago
parent
commit
e313794b12
2 changed files with 10 additions and 10 deletions
  1. 6 6
      cura/Settings/CuraContainerStack.py
  2. 4 4
      cura/Settings/MachineManager.py

+ 6 - 6
cura/Settings/CuraContainerStack.py

@@ -66,8 +66,8 @@ class CuraContainerStack(ContainerStack):
     ##  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".
-    def setQualityChanges(self, new_quality_changes: InstanceContainer) -> None:
-        self.replaceContainer(_ContainerIndexes.QualityChanges, new_quality_changes)
+    def setQualityChanges(self, new_quality_changes: InstanceContainer, postpone_emit = False) -> None:
+        self.replaceContainer(_ContainerIndexes.QualityChanges, new_quality_changes, postpone_emit = postpone_emit)
 
     ##  Set the quality changes container by an ID.
     #
@@ -93,8 +93,8 @@ class CuraContainerStack(ContainerStack):
     ##  Set the quality container.
     #
     #   \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:
-        self.replaceContainer(_ContainerIndexes.Quality, new_quality)
+    def setQuality(self, new_quality: InstanceContainer, postpone_emit = False) -> None:
+        self.replaceContainer(_ContainerIndexes.Quality, new_quality, postpone_emit = postpone_emit)
 
     ##  Set the quality container by an ID.
     #
@@ -131,8 +131,8 @@ class CuraContainerStack(ContainerStack):
     ##  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".
-    def setMaterial(self, new_material: InstanceContainer) -> None:
-        self.replaceContainer(_ContainerIndexes.Material, new_material)
+    def setMaterial(self, new_material: InstanceContainer, postpone_emit = False) -> None:
+        self.replaceContainer(_ContainerIndexes.Material, new_material, postpone_emit = postpone_emit)
 
     ##  Set the material container by an ID.
     #

+ 4 - 4
cura/Settings/MachineManager.py

@@ -835,8 +835,8 @@ class MachineManager(QObject):
 
                 name_changed_connect_stacks.append(stack_quality)
                 name_changed_connect_stacks.append(stack_quality_changes)
-                self._replaceQualityOrQualityChangesInStack(stack, stack_quality)
-                self._replaceQualityOrQualityChangesInStack(stack, stack_quality_changes)
+                self._replaceQualityOrQualityChangesInStack(stack, stack_quality, postpone_emit=True)
+                self._replaceQualityOrQualityChangesInStack(stack, stack_quality_changes, postpone_emit=True)
 
             # Send emits that are postponed in replaceContainer.
             # 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")
         if container_type == "quality":
             stack.quality.nameChanged.disconnect(self._onQualityNameChanged)
-            stack.setQuality(container)
+            stack.setQuality(container, postpone_emit = postpone_emit)
             stack.qualityChanges.nameChanged.connect(self._onQualityNameChanged)
         elif container_type == "quality_changes" or container_type is None:
             # If the container is an empty container, we need to change the quality_changes.
             # Quality can never be set to empty.
             stack.qualityChanges.nameChanged.disconnect(self._onQualityNameChanged)
-            stack.setQualityChanges(container)
+            stack.setQualityChanges(container, postpone_emit = postpone_emit)
             stack.qualityChanges.nameChanged.connect(self._onQualityNameChanged)
         self._onQualityNameChanged()