From e2699a5ab86a3babedf337200a2d3eb421eba230 Mon Sep 17 00:00:00 2001 From: Kostas Karmas Date: Fri, 5 Feb 2021 12:10:23 +0100 Subject: [PATCH] Display the correct message when opening deleted files from Recent If a file that existed in the Recent Files list was deleted, Cura was still trying to open the file on user's request without properly displaying an error if the file was not found. This is now fixed by popping up a message to indicate that the file doesn't exist. CURA-7996 --- cura/CuraApplication.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 9493153bf7..263d25b783 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1743,6 +1743,7 @@ class CuraApplication(QtApplication): :param project_mode: How to handle project files. Either None(default): Follow user preference, "open_as_model" or "open_as_project". This parameter is only considered if the file is a project file. + :param add_to_recent_files: Whether or not to add the file as an option to the Recent Files list. """ Logger.log("i", "Attempting to read file %s", file.toString()) if not file.isValid(): @@ -1757,6 +1758,10 @@ class CuraApplication(QtApplication): is_project_file = self.checkIsValidProjectFile(file) + if is_project_file is False: + # The file isn't a valid project file so abort reading it. + return + if project_mode is None: project_mode = self.getPreferences().getValue("cura/choice_on_open_project") @@ -1940,6 +1945,13 @@ class CuraApplication(QtApplication): try: result = workspace_reader.preRead(file_path, show_dialog=False) return result == WorkspaceReader.PreReadResult.accepted + except FileNotFoundError: + result_message = Message(text = self._i18n_catalog.i18nc("@info:status Don't translate the XML tag !", + "Failed to load {0}. No such file or directory.", + file_path), lifetime = 0, + title = self._i18n_catalog.i18nc("@info:title", "Unable to Open File")) + result_message.show() + return False except Exception: Logger.logException("e", "Could not check file %s", file_url) return False