Browse Source

Updating when new definition changes should be created when loading project - CURA-4413

Diego Prado Gesto 7 years ago
parent
commit
104926c6ed

+ 4 - 2
plugins/3MFReader/ThreeMFWorkspaceReader.py

@@ -222,10 +222,12 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
             elif container_type == "definition_changes":
                 definition_name = instance_container.getName()
                 num_settings_overriden_by_definition_changes += len(instance_container._instances)
+                # Check if definition changes already exists.
                 definition_changes = self._container_registry.findInstanceContainers(id = container_id)
-                containers_found_dict["definition_changes"] = True
                 # Check if there is any difference the loaded settings from the project file and the settings in Cura.
                 if definition_changes:
+                    containers_found_dict["definition_changes"] = True
+                    # Check if there really is a conflict by comparing the values
                     if definition_changes[0] != instance_container:
                         definition_changes_conflict = True
             elif container_type == "quality":
@@ -357,7 +359,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
         #  - new:       create a new container
         #  - override:  override the existing container
         #  - None:      There is no conflict, which means containers with the same IDs may or may not be there already.
-        #               If there is an existing container, there is no conflict between the them, and default to "override"
+        #               If there is an existing container, there is no conflict between them, and default to "override"
         #               If there is no existing container, default to "new"
         #
         # Default values

+ 5 - 3
plugins/3MFReader/WorkspaceDialog.py

@@ -233,13 +233,15 @@ class WorkspaceDialog(QObject):
             self._result["quality_changes"] = None
         if "definition_changes" in self._result and not self._has_definition_changes_conflict:
             self._result["definition_changes"] = None
+        if "material" in self._result and not self._has_material_conflict:
+            self._result["material"] = None
 
         # If the machine needs to be re-created, the definition_changes should also be re-created.
-        if "machine" in self._result and self._result["machine"] == "new" and self._result["definition_changes"] is None:
+        # If the machine strategy is None, it means that there is no name conflict with existing ones. In this case
+        # new definitions changes are created
+        if "machine" in self._result and self._result["machine"] == "new" or self._result["machine"] is None and self._result["definition_changes"] is None:
             self._result["definition_changes"] = "new"
 
-        if "material" in self._result and not self._has_material_conflict:
-            self._result["material"] = None
         return self._result
 
     def _createViewFromQML(self):