From 831a1d4876fc5d12c786c2b93a0ebe9c2fbf3728 Mon Sep 17 00:00:00 2001 From: Saumya Jain Date: Wed, 6 Mar 2024 12:32:05 +0100 Subject: [PATCH] Reset openAsUcp at the start of preread CURA-11403 --- cura/CuraApplication.py | 3 ++- plugins/3MFReader/ThreeMFWorkspaceReader.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 5de74e4714..86bb53126c 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1986,7 +1986,6 @@ class CuraApplication(QtApplication): Logger.warning(f"Workspace reader not found, cannot read file {file_name}.") return - workspace_reader.getReaderForFile(file_name).setOpenAsUcp(True) workspace_reader.readLocalFile(file, add_to_recent_files) @pyqtSlot(QUrl, str, bool) @@ -2209,6 +2208,8 @@ class CuraApplication(QtApplication): if workspace_reader is None: return False # non-project files won't get a reader try: + if workspace_reader.getPluginId() == "3MFReader": + workspace_reader.clearOpenAsUcp() result = workspace_reader.preRead(file_path, show_dialog=False) return result == WorkspaceReader.PreReadResult.accepted except: diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 75b04db9e3..e6992611c1 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -152,8 +152,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader): self._machine_info = None self._user_settings = {} - def setOpenAsUcp(self, openAsUcp: bool): - self._is_ucp = openAsUcp + def clearOpenAsUcp(self): + self._is_ucp = None def getNewId(self, old_id: str): """Get a unique name based on the old_id. This is different from directly calling the registry in that it caches results. @@ -208,6 +208,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): raise FileNotFoundError("No global stack file found!") return global_stack_file_list[0], extruder_stack_file_list + def _isProjectUcp(self, file_name) -> bool: if self._is_ucp == None: archive = zipfile.ZipFile(file_name, "r")