mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
CURA-4386 CURA-4379 change stack behaviours to fix crashes
This commit is contained in:
parent
e3edc79a3e
commit
1b8766b953
6 changed files with 34 additions and 29 deletions
|
@ -41,7 +41,7 @@ class ExtruderManager(QObject):
|
|||
def __init__(self, parent = None):
|
||||
super().__init__(parent)
|
||||
self._extruder_trains = { } #Per machine, a dictionary of extruder container stack IDs. Only for separately defined extruders.
|
||||
self._active_extruder_index = 0
|
||||
self._active_extruder_index = -1
|
||||
self._selected_object_extruders = []
|
||||
Application.getInstance().globalContainerStackChanged.connect(self.__globalContainerStackChanged)
|
||||
self._global_container_stack_definition_id = None
|
||||
|
@ -78,6 +78,7 @@ class ExtruderManager(QObject):
|
|||
def extruderIds(self):
|
||||
map = {}
|
||||
global_stack_id = Application.getInstance().getGlobalContainerStack().getId()
|
||||
map["-1"] = global_stack_id
|
||||
if global_stack_id in self._extruder_trains:
|
||||
for position in self._extruder_trains[global_stack_id]:
|
||||
map[position] = self._extruder_trains[global_stack_id][position].getId()
|
||||
|
@ -513,11 +514,16 @@ class ExtruderManager(QObject):
|
|||
global_stack = Application.getInstance().getGlobalContainerStack()
|
||||
|
||||
result = []
|
||||
machine_extruder_count = global_stack.getProperty("machine_extruder_count", "value")
|
||||
|
||||
if machine_extruder_count is 1:
|
||||
return result
|
||||
|
||||
if global_stack and global_stack.getId() in self._extruder_trains:
|
||||
for extruder in sorted(self._extruder_trains[global_stack.getId()]):
|
||||
result.append(self._extruder_trains[global_stack.getId()][extruder])
|
||||
|
||||
return result[:global_stack.getProperty("machine_extruder_count", "value")]
|
||||
return result[:machine_extruder_count]
|
||||
|
||||
def __globalContainerStackChanged(self) -> None:
|
||||
global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||
|
|
|
@ -271,7 +271,6 @@ class MachineManager(QObject):
|
|||
extruder_stack.containersChanged.disconnect(self._onInstanceContainersChanged)
|
||||
|
||||
self._global_container_stack = Application.getInstance().getGlobalContainerStack()
|
||||
self._active_container_stack = self._global_container_stack
|
||||
|
||||
self.globalContainerChanged.emit()
|
||||
|
||||
|
@ -303,6 +302,9 @@ class MachineManager(QObject):
|
|||
|
||||
quality = self._global_container_stack.quality
|
||||
quality.nameChanged.connect(self._onQualityNameChanged)
|
||||
|
||||
self._active_container_stack = self._global_container_stack
|
||||
|
||||
self._error_check_timer.start()
|
||||
|
||||
## Update self._stacks_valid according to _checkStacksForErrors and emit if change.
|
||||
|
@ -547,12 +549,14 @@ class MachineManager(QObject):
|
|||
def allActiveMaterialIds(self) -> Dict[str, str]:
|
||||
result = {}
|
||||
active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
|
||||
if active_stacks is not None: #If we have a global stack.
|
||||
|
||||
result[self._global_container_stack.getId()] = self._global_container_stack.material.getId()
|
||||
|
||||
if active_stacks is not None: # If we have extruder stacks
|
||||
for stack in active_stacks:
|
||||
material_container = stack.material
|
||||
if not material_container:
|
||||
continue
|
||||
|
||||
result[stack.getId()] = material_container.getId()
|
||||
|
||||
return result
|
||||
|
|
|
@ -219,6 +219,7 @@ class MachineSettingsAction(MachineAction):
|
|||
machine_manager.setActiveVariant(extruder_variant_id)
|
||||
|
||||
preferences.setValue("cura/choice_on_profile_override", choice_on_profile_override)
|
||||
|
||||
self.forceUpdate()
|
||||
|
||||
|
||||
|
|
|
@ -39,11 +39,8 @@ Menu
|
|||
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].materialNames.length > extruderIndex
|
||||
onTriggered:
|
||||
{
|
||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
var materialId = Cura.MachineManager.printerOutputDevices[0].materialIds[extruderIndex];
|
||||
var items = materialsModel.items;
|
||||
// materialsModel.find cannot be used because we need to look inside the metadata property of items
|
||||
for(var i in items)
|
||||
{
|
||||
if (items[i]["metadata"]["GUID"] == materialId)
|
||||
|
@ -52,7 +49,6 @@ Menu
|
|||
break;
|
||||
}
|
||||
}
|
||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,13 +66,7 @@ Menu
|
|||
checkable: true
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||
exclusiveGroup: group
|
||||
onTriggered:
|
||||
{
|
||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
Cura.MachineManager.setActiveMaterial(model.id);
|
||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
}
|
||||
onTriggered: Cura.MachineManager.setActiveMaterial(model.id)
|
||||
}
|
||||
onObjectAdded: menu.insertItem(index, object)
|
||||
onObjectRemoved: menu.removeItem(object)
|
||||
|
@ -111,13 +101,7 @@ Menu
|
|||
checkable: true
|
||||
checked: model.id == Cura.MachineManager.allActiveMaterialIds[ExtruderManager.extruderIds[extruderIndex]]
|
||||
exclusiveGroup: group
|
||||
onTriggered:
|
||||
{
|
||||
var activeExtruderIndex = ExtruderManager.activeExtruderIndex;
|
||||
ExtruderManager.setActiveExtruderIndex(extruderIndex);
|
||||
Cura.MachineManager.setActiveMaterial(model.id);
|
||||
ExtruderManager.setActiveExtruderIndex(activeExtruderIndex);
|
||||
}
|
||||
onTriggered: Cura.MachineManager.setActiveMaterial(model.id)
|
||||
}
|
||||
onObjectAdded: brandMaterialsMenu.insertItem(index, object)
|
||||
onObjectRemoved: brandMaterialsMenu.removeItem(object)
|
||||
|
|
|
@ -91,12 +91,7 @@ Column
|
|||
Connections
|
||||
{
|
||||
target: Cura.MachineManager
|
||||
onGlobalContainerChanged:
|
||||
{
|
||||
forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
|
||||
// var extruder_index = (machineExtruderCount.properties.value == 1) ? -1 : 0
|
||||
// ExtruderManager.setActiveExtruderIndex(extruder_index);
|
||||
}
|
||||
onGlobalContainerChanged: forceActiveFocus() // Changing focus applies the currently-being-typed values so it can change the displayed setting values.
|
||||
}
|
||||
|
||||
delegate: Button
|
||||
|
@ -294,6 +289,15 @@ Column
|
|||
|
||||
menu: MaterialMenu { extruderIndex: base.currentExtruderIndex }
|
||||
}
|
||||
|
||||
Connections
|
||||
{
|
||||
target: Cura.MachineManager
|
||||
onGlobalContainerChanged:
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Print core row
|
||||
|
|
|
@ -68,6 +68,12 @@ Item
|
|||
onActiveQualityChanged: qualityModel.update()
|
||||
}
|
||||
|
||||
Connections
|
||||
{
|
||||
target: Cura.MachineManager
|
||||
onActiveMaterialChanged: qualityModel.update()
|
||||
}
|
||||
|
||||
ListModel
|
||||
{
|
||||
id: qualityModel
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue