Move some things outside of try-catch clause

Only the pre-read should really be in there. Otherwise we'd hide some mistakes in our code.

Contributes to issue CURA-4810.
This commit is contained in:
Ghostkeeper 2018-01-16 10:39:08 +01:00
parent 1e892dc45c
commit 27c0ca4dea
No known key found for this signature in database
GPG Key ID: 5252B696FB5E7C7A

View File

@ -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: