mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-18 20:28:01 -06:00
Fix removeMaterial.
The base_file must be removed first, or it gets loaded halfway during remove containers. Contributes to issue CURA-4243.
This commit is contained in:
parent
7d24933835
commit
eb171231c2
3 changed files with 10 additions and 2 deletions
|
@ -118,7 +118,7 @@ class ContainerManager(QObject):
|
||||||
def removeContainer(self, container_id):
|
def removeContainer(self, container_id):
|
||||||
containers = self._container_registry.findContainers(id = container_id)
|
containers = self._container_registry.findContainers(id = container_id)
|
||||||
if not containers:
|
if not containers:
|
||||||
Logger.log("w", "Could remove container %s because it was not found.", container_id)
|
Logger.log("w", "Could not remove container %s because it was not found.", container_id)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
self._container_registry.removeContainer(containers[0].getId())
|
self._container_registry.removeContainer(containers[0].getId())
|
||||||
|
|
|
@ -32,5 +32,6 @@ class MaterialsModel(InstanceContainersModel):
|
||||||
result.append(item["metadata"]["material"])
|
result.append(item["metadata"]["material"])
|
||||||
result.append(item["metadata"]["name"])
|
result.append(item["metadata"]["name"])
|
||||||
result.append(item["metadata"]["color_name"])
|
result.append(item["metadata"]["color_name"])
|
||||||
|
result.append(item["metadata"]["id"])
|
||||||
result.extend(super()._sortKey(item))
|
result.extend(super()._sortKey(item))
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -182,6 +182,7 @@ UM.ManagementPage
|
||||||
{
|
{
|
||||||
Cura.MachineManager.setActiveMaterial(material_id)
|
Cura.MachineManager.setActiveMaterial(material_id)
|
||||||
}
|
}
|
||||||
|
// TODO: this doesn't work because the source is a bit delayed
|
||||||
base.objectList.currentIndex = base.getIndexById(material_id);
|
base.objectList.currentIndex = base.getIndexById(material_id);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -292,10 +293,16 @@ UM.ManagementPage
|
||||||
base_file = base.currentItem.id
|
base_file = base.currentItem.id
|
||||||
}
|
}
|
||||||
var guid = Cura.ContainerManager.getContainerMetaDataEntry(base.currentItem.id, "GUID")
|
var guid = Cura.ContainerManager.getContainerMetaDataEntry(base.currentItem.id, "GUID")
|
||||||
|
// remove base container first, it otherwise triggers loading the base file while removing other containers
|
||||||
|
var base_containers = Cura.ContainerManager.findInstanceContainers({"GUID": guid, "id": base_file, "base_file": base_file, "type": "material"})
|
||||||
|
for(var i in base_containers)
|
||||||
|
{
|
||||||
|
Cura.ContainerManager.removeContainer(base_containers[i]);
|
||||||
|
}
|
||||||
var containers = Cura.ContainerManager.findInstanceContainers({"GUID": guid, "base_file": base_file, "type": "material"})
|
var containers = Cura.ContainerManager.findInstanceContainers({"GUID": guid, "base_file": base_file, "type": "material"})
|
||||||
for(var i in containers)
|
for(var i in containers)
|
||||||
{
|
{
|
||||||
Cura.ContainerManager.removeContainer(containers[i])
|
Cura.ContainerManager.removeContainer(containers[i]);
|
||||||
}
|
}
|
||||||
if(base.objectList.currentIndex > 0)
|
if(base.objectList.currentIndex > 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue