From 03c28537f2d20970a3ef2b09918f8eb823480dd1 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 12 Sep 2016 11:58:51 +0200 Subject: [PATCH 1/3] Added function to save a single stack to file. CURA-2279 --- cura/CuraApplication.py | 44 +++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 7651cad930..f6cf0692f7 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -327,29 +327,31 @@ class CuraApplication(QtApplication): f.write(data) for stack in ContainerRegistry.getInstance().findContainerStacks(): - if not stack.isDirty(): - continue + self.saveStack(stack) - try: - data = stack.serialize() - except NotImplementedError: - continue - except Exception: - Logger.logException("e", "An exception occurred when serializing container %s", instance.getId()) - continue + def saveStack(self, stack): + if not stack.isDirty(): + return + try: + data = stack.serialize() + except NotImplementedError: + return + except Exception: + Logger.logException("e", "An exception occurred when serializing container %s", stack.getId()) + return - mime_type = ContainerRegistry.getMimeTypeForContainer(type(stack)) - file_name = urllib.parse.quote_plus(stack.getId()) + "." + mime_type.preferredSuffix - stack_type = stack.getMetaDataEntry("type", None) - path = None - if not stack_type or stack_type == "machine": - path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name) - elif stack_type == "extruder_train": - path = Resources.getStoragePath(self.ResourceTypes.ExtruderStack, file_name) - if path: - stack.setPath(path) - with SaveFile(path, "wt", -1, "utf-8") as f: - f.write(data) + mime_type = ContainerRegistry.getMimeTypeForContainer(type(stack)) + file_name = urllib.parse.quote_plus(stack.getId()) + "." + mime_type.preferredSuffix + stack_type = stack.getMetaDataEntry("type", None) + path = None + if not stack_type or stack_type == "machine": + path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name) + elif stack_type == "extruder_train": + path = Resources.getStoragePath(self.ResourceTypes.ExtruderStack, file_name) + if path: + stack.setPath(path) + with SaveFile(path, "wt", -1, "utf-8") as f: + f.write(data) @pyqtSlot(str, result = QUrl) From 12b967ddb252f150caf59b26072675eb8b545c9e Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 12 Sep 2016 12:58:35 +0200 Subject: [PATCH 2/3] Remove debug code Don't know who it was or why or when, but it shouldn't be there. --- resources/qml/SidebarHeader.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index 6f9338d23c..eb465574a2 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -235,7 +235,6 @@ Column property var valueError: { var data = Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible") - print(data) if(data == "" || data == "True") { return false From 44092f0b96c20eb8cfa75876cb23661c18fc06b0 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 12 Sep 2016 13:00:01 +0200 Subject: [PATCH 3/3] Printers with a quality_definition now also create quality changes using that definition CURA-1780 --- cura/Settings/ContainerManager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index f7ea9bd416..dcc2b5e863 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -746,7 +746,10 @@ class ContainerManager(QObject): if not global_stack.getMetaDataEntry("has_machine_quality"): quality_changes.setDefinition(self._container_registry.findContainers(id = "fdmprinter")[0]) else: - quality_changes.setDefinition(global_stack.getBottom()) + definition = global_stack.getBottom() + definition_id = definition.getMetaDataEntry("quality_definition", definition.getId()) + definition = self._container_registry.findContainers(id=definition_id)[0] + quality_changes.setDefinition(definition) if global_stack.getMetaDataEntry("has_materials"): material = quality_container.getMetaDataEntry("material")