diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 099c71c708..402917d748 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1518,12 +1518,11 @@ class CuraApplication(QtApplication): """ Checks if the given file URL is a valid project file. """ + file_path = QUrl(file_url).toLocalFile() + workspace_reader = self.getWorkspaceFileHandler().getReaderForFile(file_path) + if workspace_reader is None: + return False # non-project files won't get a reader try: - file_path = QUrl(file_url).toLocalFile() - workspace_reader = self.getWorkspaceFileHandler().getReaderForFile(file_path) - if workspace_reader is None: - return False # non-project files won't get a reader - result = workspace_reader.preRead(file_path, show_dialog=False) return result == WorkspaceReader.PreReadResult.accepted except Exception as e: diff --git a/cura/Settings/ExtruderManager.py b/cura/Settings/ExtruderManager.py index 351843ae14..b5f9a35914 100755 --- a/cura/Settings/ExtruderManager.py +++ b/cura/Settings/ExtruderManager.py @@ -49,6 +49,9 @@ class ExtruderManager(QObject): ## Notify when the user switches the currently active extruder. activeExtruderChanged = pyqtSignal() + ## The signal notifies subscribers if extruders are added + extrudersAdded = pyqtSignal() + ## Gets the unique identifier of the currently active extruder stack. # # The currently active extruder stack is the stack that is currently being @@ -406,6 +409,7 @@ class ExtruderManager(QObject): if extruders_changed: self.extrudersChanged.emit(global_stack_id) + self.extrudersAdded.emit() self.setActiveExtruderIndex(0) ## Get all extruder values for a certain setting. diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 5c62c361c3..77a7da8b6a 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -168,11 +168,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader): Logger.log("w", "Unknown definition container type %s for %s", definition_container_type, each_definition_container_file) Job.yieldThread() - # sanity check + if machine_definition_container_count != 1: - msg = "Expecting one machine definition container but got %s" % machine_definition_container_count - Logger.log("e", msg) - raise RuntimeError(msg) + return WorkspaceReader.PreReadResult.failed #Not a workspace file but ordinary 3MF. material_labels = [] material_conflict = False @@ -271,7 +269,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader): # if the global stack is found, we check if there are conflicts in the extruder stacks if containers_found_dict["machine"] and not machine_conflict: for extruder_stack_file in extruder_stack_files: - container_id = self._stripFileToId(extruder_stack_file) serialized = archive.open(extruder_stack_file).read().decode("utf-8") parser = configparser.ConfigParser() parser.read_string(serialized) @@ -303,7 +300,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader): break num_visible_settings = 0 - has_visible_settings_string = False try: temp_preferences = Preferences() serialized = archive.open("Cura/preferences.cfg").read().decode("utf-8") diff --git a/plugins/CuraEngineBackend/CuraEngineBackend.py b/plugins/CuraEngineBackend/CuraEngineBackend.py index 97463e07da..9713211ad3 100755 --- a/plugins/CuraEngineBackend/CuraEngineBackend.py +++ b/plugins/CuraEngineBackend/CuraEngineBackend.py @@ -88,6 +88,7 @@ class CuraEngineBackend(QObject, Backend): # self._global_container_stack = None Application.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged) + Application.getInstance().getExtruderManager().extrudersAdded.connect(self._onGlobalStackChanged) self._onGlobalStackChanged() Application.getInstance().stacksValidationFinished.connect(self._onStackErrorCheckFinished)