InstanceContainerchanged is now also on a timer.

This greatly reduces the signal storm resulting from changing quality / material in multi extrusion machines.

CURA-3780
This commit is contained in:
Jaime van Kessel 2017-05-10 13:22:34 +02:00
parent 7a4ca25193
commit bfb76540d0

View file

@ -51,6 +51,11 @@ class MachineManager(QObject):
self._error_check_timer.setSingleShot(True) self._error_check_timer.setSingleShot(True)
self._error_check_timer.timeout.connect(self._updateStacksHaveErrors) self._error_check_timer.timeout.connect(self._updateStacksHaveErrors)
self._instance_container_timer = QTimer()
self._instance_container_timer.setInterval(250)
self._instance_container_timer.setSingleShot(True)
self._instance_container_timer.timeout.connect(self.__onInstanceContainersChanged)
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged) Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
## When the global container is changed, active material probably needs to be updated. ## When the global container is changed, active material probably needs to be updated.
self.globalContainerChanged.connect(self.activeMaterialChanged) self.globalContainerChanged.connect(self.activeMaterialChanged)
@ -317,23 +322,15 @@ class MachineManager(QObject):
# on _active_container_stack. If it changes, then the properties change. # on _active_container_stack. If it changes, then the properties change.
self.activeQualityChanged.emit() self.activeQualityChanged.emit()
def _onInstanceContainersChanged(self, container): def __onInstanceContainersChanged(self):
container_type = container.getMetaDataEntry("type")
if container_type == "quality":
self.activeQualityChanged.emit()
elif container_type == "variant":
self.activeVariantChanged.emit()
elif container_type == "material":
self.activeMaterialChanged.emit()
else:
# We don't know which one it is, send all the signals
self.activeQualityChanged.emit() self.activeQualityChanged.emit()
self.activeVariantChanged.emit() self.activeVariantChanged.emit()
self.activeMaterialChanged.emit() self.activeMaterialChanged.emit()
self._error_check_timer.start() self._error_check_timer.start()
def _onInstanceContainersChanged(self, container):
self._instance_container_timer.start()
def _onPropertyChanged(self, key, property_name): def _onPropertyChanged(self, key, property_name):
if property_name == "value": if property_name == "value":
# Notify UI items, such as the "changed" star in profile pull down menu. # Notify UI items, such as the "changed" star in profile pull down menu.