mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 11:47:50 -06:00
Fix empty definition_changes check in MachineSettingsAction
CURA-5060 Should check for both "empty" and "empty_definition_changes".
This commit is contained in:
parent
c9905449eb
commit
206d20c440
1 changed files with 13 additions and 7 deletions
|
@ -34,10 +34,16 @@ class MachineSettingsAction(MachineAction):
|
||||||
self._container_registry.containerRemoved.connect(self._onContainerRemoved)
|
self._container_registry.containerRemoved.connect(self._onContainerRemoved)
|
||||||
self._application.globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
self._application.globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
||||||
|
|
||||||
self._empty_container = self._container_registry.getEmptyInstanceContainer()
|
|
||||||
|
|
||||||
self._backend = self._application.getBackend()
|
self._backend = self._application.getBackend()
|
||||||
|
|
||||||
|
self._empty_definition_container_id_list = []
|
||||||
|
|
||||||
|
def _isEmptyDefinitionChanges(self, container_id: str):
|
||||||
|
if not self._empty_definition_container_id_list:
|
||||||
|
self._empty_definition_container_id_list = [self._application.empty_container.getId(),
|
||||||
|
self._application.empty_definition_changes_container.getId()]
|
||||||
|
return container_id in self._empty_definition_container_id_list
|
||||||
|
|
||||||
def _onContainerAdded(self, container):
|
def _onContainerAdded(self, container):
|
||||||
# Add this action as a supported action to all machine definitions
|
# Add this action as a supported action to all machine definitions
|
||||||
if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine":
|
if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine":
|
||||||
|
@ -46,19 +52,19 @@ class MachineSettingsAction(MachineAction):
|
||||||
def _onContainerRemoved(self, container):
|
def _onContainerRemoved(self, container):
|
||||||
# Remove definition_changes containers when a stack is removed
|
# Remove definition_changes containers when a stack is removed
|
||||||
if container.getMetaDataEntry("type") in ["machine", "extruder_train"]:
|
if container.getMetaDataEntry("type") in ["machine", "extruder_train"]:
|
||||||
definition_changes_container = container.definitionChanges
|
definition_changes_id = container.definitionChanges.getId()
|
||||||
if definition_changes_container == self._empty_container:
|
if self._isEmptyDefinitionChanges(definition_changes_id):
|
||||||
return
|
return
|
||||||
|
|
||||||
self._container_registry.removeContainer(definition_changes_container.getId())
|
self._container_registry.removeContainer(definition_changes_id)
|
||||||
|
|
||||||
def _reset(self):
|
def _reset(self):
|
||||||
if not self._global_container_stack:
|
if not self._global_container_stack:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Make sure there is a definition_changes container to store the machine settings
|
# Make sure there is a definition_changes container to store the machine settings
|
||||||
definition_changes_container = self._global_container_stack.definitionChanges
|
definition_changes_id = self._global_container_stack.definitionChanges.getId()
|
||||||
if definition_changes_container == self._empty_container:
|
if self._isEmptyDefinitionChanges(definition_changes_id):
|
||||||
CuraStackBuilder.createDefinitionChangesContainer(self._global_container_stack,
|
CuraStackBuilder.createDefinitionChangesContainer(self._global_container_stack,
|
||||||
self._global_container_stack.getName() + "_settings")
|
self._global_container_stack.getName() + "_settings")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue