From 566af8be2e355b6ed7017272f243f27d03409f69 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 23 Mar 2020 09:06:20 +0100 Subject: [PATCH] Don't crash when importing definition files as materials Reproduction steps: * In the Material Manager, click on 'Import material'. * Change the file type in the file dialogue to 'All files'. * Select any .def.json file, for example from Cura's own resources/definitions folder. Previously this crashed the application. Now it shows the user an error message instead. Fixes Sentry error CURA-D4. --- cura/Settings/ContainerManager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index 92f06929d2..9514f80e34 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -239,6 +239,8 @@ class ContainerManager(QObject): container_type = container_registry.getContainerForMimeType(mime_type) if not container_type: return {"status": "error", "message": "Could not find a container to handle the specified file."} + if not issubclass(container_type, InstanceContainer): + return {"status": "error", "message": "This is not a material container, but another type of file."} container_id = urllib.parse.unquote_plus(mime_type.stripExtension(os.path.basename(file_url))) container_id = container_registry.uniqueName(container_id)