Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2019-09-17 09:55:29 +0300
committerGhostkeeper <rubend@tutanota.com>2019-09-17 09:55:29 +0300
commit977beb8dbb0aa92c7dc450a2cbfbbb65ab53faf9 (patch)
treee8ba22f3c054bf5bfe1707fb89935dab03c17bbe /plugins/MachineSettingsAction
parent9b341cf604a856d6aca5ecb861490db938439e21 (diff)
Re-build container tree if has_materials changes during runtime
A bit of a hack and it'll be very slow. But it should work. Right now this crashes though because it still calls the Material Manager. Contributes to issue CURA-6600.
Diffstat (limited to 'plugins/MachineSettingsAction')
-rwxr-xr-xplugins/MachineSettingsAction/MachineSettingsAction.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/plugins/MachineSettingsAction/MachineSettingsAction.py b/plugins/MachineSettingsAction/MachineSettingsAction.py
index d48475b1e6..a0ce51df9b 100755
--- a/plugins/MachineSettingsAction/MachineSettingsAction.py
+++ b/plugins/MachineSettingsAction/MachineSettingsAction.py
@@ -11,7 +11,9 @@ from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Settings.DefinitionContainer import DefinitionContainer
from UM.Util import parseBool
+import cura.CuraApplication # Imported like this to prevent circular dependencies.
from cura.MachineAction import MachineAction
+from cura.Machines.ContainerTree import ContainerTree # To re-build the machine node when hasMaterials changes.
from cura.Settings.CuraStackBuilder import CuraStackBuilder
from cura.Settings.cura_empty_instance_containers import isEmptyContainer
@@ -41,6 +43,9 @@ class MachineSettingsAction(MachineAction):
self._backend = self._application.getBackend()
self.onFinished.connect(self._onFinished)
+ # If the g-code flavour changes between UltiGCode and another flavour, we need to update the container tree.
+ self._application.globalContainerStackChanged.connect(self._updateHasMaterialsInContainerTree)
+
# Which container index in a stack to store machine setting changes.
@pyqtProperty(int, constant = True)
def storeContainerIndex(self) -> int:
@@ -51,6 +56,16 @@ class MachineSettingsAction(MachineAction):
if isinstance(container, DefinitionContainer) and container.getMetaDataEntry("type") == "machine":
self._application.getMachineActionManager().addSupportedAction(container.getId(), self.getKey())
+ ## Triggered when the global container stack changes or when the g-code
+ # flavour setting is changed.
+ def _updateHasMaterialsInContainerTree(self) -> None:
+ global_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
+ machine_node = ContainerTree.getInstance().machines[global_stack.definition.getId()]
+
+ if machine_node.has_materials != parseBool(global_stack.getMetaDataEntry("has_materials")): # May have changed due to the g-code flavour.
+ machine_node.has_materials = parseBool(global_stack.getMetaDataEntry("has_materials"))
+ machine_node._loadAll()
+
def _reset(self):
global_stack = self._application.getMachineManager().activeMachine
if not global_stack:
@@ -111,6 +126,8 @@ class MachineSettingsAction(MachineAction):
if "has_materials" in global_stack.getMetaData():
global_stack.removeMetaDataEntry("has_materials")
+ self._updateHasMaterialsInContainerTree()
+
# set materials
for position in extruder_positions:
if has_materials: