mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 04:07:57 -06:00
Remove double call of _onGlobalContainerChanged and activeExtruderChanged on switching
When switching printers, it would first emit the global container changed signal which connects to _onGlobalContainerChanged, then update stuff in the extruder manager, then manually call _onGlobalContainerChanged again to update some other stuff with the new data from the extruder manager. This was prohibitively expensive, so this prevents that. Another double or triple emit of the activeExtruderChanged was removed in the extruder manager when creating the extruders for a printer: It would first set the extruder number to 0, possibly emitting the signal, then emit the signal just to be sure since the extruder itself changed (rather than just the number), and then change the extruder number to the preferred extruder, possibly again emitting a signal. Now it just sets the extruder number to the preferred extruder and always emits the signal once (either through setting the extruder number or manually afterwards). Contributes to issue CURA-6793.
This commit is contained in:
parent
dd8ee2e3d8
commit
0238f65e6a
2 changed files with 14 additions and 14 deletions
|
@ -219,7 +219,10 @@ class MachineManager(QObject):
|
|||
return 0
|
||||
return len(general_definition_containers[0].getAllKeys())
|
||||
|
||||
## Triggered when the global container stack is changed in CuraApplication.
|
||||
def _onGlobalContainerChanged(self) -> None:
|
||||
import traceback
|
||||
traceback.print_stack()
|
||||
if self._global_container_stack:
|
||||
try:
|
||||
self._global_container_stack.containersChanged.disconnect(self._onContainersChanged)
|
||||
|
@ -298,7 +301,6 @@ class MachineManager(QObject):
|
|||
self.blurSettings.emit() # Ensure no-one has focus.
|
||||
|
||||
container_registry = CuraContainerRegistry.getInstance()
|
||||
|
||||
containers = container_registry.findContainerStacks(id = stack_id)
|
||||
if not containers:
|
||||
return
|
||||
|
@ -308,21 +310,25 @@ class MachineManager(QObject):
|
|||
# Make sure that the default machine actions for this machine have been added
|
||||
self._application.getMachineActionManager().addDefaultMachineActions(global_stack)
|
||||
|
||||
ExtruderManager.getInstance().fixSingleExtrusionMachineExtruderDefinition(global_stack)
|
||||
extruder_manager = ExtruderManager.getInstance()
|
||||
extruder_manager.fixSingleExtrusionMachineExtruderDefinition(global_stack)
|
||||
if not global_stack.isValid():
|
||||
# Mark global stack as invalid
|
||||
ConfigurationErrorMessage.getInstance().addFaultyContainers(global_stack.getId())
|
||||
return # We're done here
|
||||
|
||||
self._global_container_stack = global_stack
|
||||
extruder_manager.addMachineExtruders(global_stack)
|
||||
self._application.setGlobalContainerStack(global_stack)
|
||||
ExtruderManager.getInstance()._globalContainerStackChanged()
|
||||
self._onGlobalContainerChanged()
|
||||
|
||||
# Switch to the first enabled extruder
|
||||
self.updateDefaultExtruder()
|
||||
default_extruder_position = int(self.defaultExtruderPosition)
|
||||
ExtruderManager.getInstance().setActiveExtruderIndex(default_extruder_position)
|
||||
old_active_extruder_index = extruder_manager.activeExtruderIndex
|
||||
extruder_manager.setActiveExtruderIndex(default_extruder_position)
|
||||
if old_active_extruder_index == default_extruder_position:
|
||||
# This signal might not have been emitted yet (if it didn't change) but we still want the models to update that depend on it because we changed the contents of the containers too.
|
||||
extruder_manager.activeExtruderChanged.emit()
|
||||
|
||||
self.__emitChangedSignals()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue