mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-20 13:17:51 -06:00
Fix renaming custom profile
CURA-6842
This commit is contained in:
parent
fba7a6ff33
commit
a93fd982dd
3 changed files with 24 additions and 4 deletions
|
@ -142,6 +142,7 @@ class MachineNode(ContainerNode):
|
||||||
parent = CuraApplication.getInstance())
|
parent = CuraApplication.getInstance())
|
||||||
elif groups_by_name[name].intent_category == "default": # Intent category should be stored as "default" if everything is default or as the intent if any of the extruder have an actual intent.
|
elif groups_by_name[name].intent_category == "default": # Intent category should be stored as "default" if everything is default or as the intent if any of the extruder have an actual intent.
|
||||||
groups_by_name[name].intent_category = quality_changes.get("intent_category", "default")
|
groups_by_name[name].intent_category = quality_changes.get("intent_category", "default")
|
||||||
|
|
||||||
if "position" in quality_changes: # An extruder profile.
|
if "position" in quality_changes: # An extruder profile.
|
||||||
groups_by_name[name].metadata_per_extruder[int(quality_changes["position"])] = quality_changes
|
groups_by_name[name].metadata_per_extruder[int(quality_changes["position"])] = quality_changes
|
||||||
else: # Global profile.
|
else: # Global profile.
|
||||||
|
|
|
@ -87,11 +87,23 @@ class QualityManagementModel(ListModel):
|
||||||
application = cura.CuraApplication.CuraApplication.getInstance()
|
application = cura.CuraApplication.CuraApplication.getInstance()
|
||||||
container_registry = application.getContainerRegistry()
|
container_registry = application.getContainerRegistry()
|
||||||
new_name = container_registry.uniqueName(new_name)
|
new_name = container_registry.uniqueName(new_name)
|
||||||
global_container = cast(InstanceContainer, container_registry.findContainers(id = quality_changes_group.metadata_for_global["id"])[0])
|
# CURA-6842
|
||||||
global_container.setName(new_name)
|
# FIXME: setName() will trigger metaDataChanged signal that are connected with type Qt.AutoConnection. In this
|
||||||
|
# case, setName() will trigger direct connections which in turn causes the quality changes group and the models
|
||||||
|
# to update. Because multiple containers need to be renamed, and every time a container gets renamed, updates
|
||||||
|
# gets triggered and this results in partial updates. For example, if we rename the global quality changes
|
||||||
|
# container first, the rest of the system still thinks that I have selected "my_profile" instead of
|
||||||
|
# "my_new_profile", but an update already gets triggered, and the quality changes group that's selected will
|
||||||
|
# have no container for the global stack, because "my_profile" just got renamed to "my_new_profile". This results
|
||||||
|
# in crashes because the rest of the system assumes that all data in a QualityChangesGroup will be correct.
|
||||||
|
#
|
||||||
|
# Renaming the container for the global stack in the end seems to be ok, because the assumption is mostly based
|
||||||
|
# on the quality changes container for the global stack.
|
||||||
for metadata in quality_changes_group.metadata_per_extruder.values():
|
for metadata in quality_changes_group.metadata_per_extruder.values():
|
||||||
extruder_container = cast(InstanceContainer, container_registry.findContainers(id = metadata["id"])[0])
|
extruder_container = cast(InstanceContainer, container_registry.findContainers(id = metadata["id"])[0])
|
||||||
extruder_container.setName(new_name)
|
extruder_container.setName(new_name)
|
||||||
|
global_container = cast(InstanceContainer, container_registry.findContainers(id=quality_changes_group.metadata_for_global["id"])[0])
|
||||||
|
global_container.setName(new_name)
|
||||||
|
|
||||||
quality_changes_group.name = new_name
|
quality_changes_group.name = new_name
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
from typing import Any, Dict, Optional
|
from typing import Any, Dict, Optional
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, pyqtProperty
|
from PyQt5.QtCore import QObject, pyqtProperty, pyqtSignal
|
||||||
|
|
||||||
|
|
||||||
## Data struct to group several quality changes instance containers together.
|
## Data struct to group several quality changes instance containers together.
|
||||||
|
@ -22,7 +22,14 @@ class QualityChangesGroup(QObject):
|
||||||
self.metadata_for_global = {} # type: Dict[str, Any]
|
self.metadata_for_global = {} # type: Dict[str, Any]
|
||||||
self.metadata_per_extruder = {} # type: Dict[int, Dict[str, Any]]
|
self.metadata_per_extruder = {} # type: Dict[int, Dict[str, Any]]
|
||||||
|
|
||||||
@pyqtProperty(str, constant = True)
|
nameChanged = pyqtSignal()
|
||||||
|
|
||||||
|
def setName(self, name: str) -> None:
|
||||||
|
if self._name != name:
|
||||||
|
self._name = name
|
||||||
|
self.nameChanged.emit()
|
||||||
|
|
||||||
|
@pyqtProperty(str, fset = setName, notify = nameChanged)
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
return self._name
|
return self._name
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue