From 715e5a890ea9d2640b1d73749a0c960e8a05b5c5 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 25 May 2020 17:05:55 +0200 Subject: [PATCH] Don't crash when the file is deleted while in pre-read phase The pre-read takes a while since it shows a dialogue. The user has all the time to delete the file or rename it in the meanwhile. Fixes Sentry issue CURA-SG. --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 6ab72b029c..6c3c296d28 100755 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -589,7 +589,15 @@ class ThreeMFWorkspaceReader(WorkspaceReader): def read(self, file_name): application = CuraApplication.getInstance() - archive = zipfile.ZipFile(file_name, "r") + try: + archive = zipfile.ZipFile(file_name, "r") + except EnvironmentError as e: + message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tags or !", + "Project file {0} is suddenly inaccessible: {1}.", file_name, str(e)), + title = i18n_catalog.i18nc("@info:title", "Can't Open Project File")) + message.show() + self.setWorkspaceName("") + return [], {} cura_file_names = [name for name in archive.namelist() if name.startswith("Cura/")]