Allow getContainer() to return None

And in the rest of the locations we must then check if it's None and handle that gracefully.
Here we assume that the getContainer message shows a message to the user if necessary. For now we'll just log it.

Contributes to issue CURA-5045.
This commit is contained in:
Ghostkeeper 2018-03-26 15:48:03 +02:00
parent 2a39d81a3c
commit 6d3fed8f52
No known key found for this signature in database
GPG key ID: 5252B696FB5E7C7A
9 changed files with 52 additions and 23 deletions

View file

@ -423,7 +423,8 @@ class MaterialManager(QObject):
return
material_group = self.getMaterialGroup(root_material_id)
material_group.root_material_node.getContainer().setName(name)
if material_group:
material_group.root_material_node.getContainer().setName(name)
#
# Removes the given material.
@ -447,6 +448,8 @@ class MaterialManager(QObject):
return None
base_container = material_group.root_material_node.getContainer()
if not base_container:
return None
# Ensure all settings are saved.
self._application.saveSettings()
@ -466,6 +469,8 @@ class MaterialManager(QObject):
# Clone all of them.
for node in material_group.derived_material_node_list:
container_to_copy = node.getContainer()
if not container_to_copy:
continue
# Create unique IDs for every clone.
new_id = new_base_id
if container_to_copy.getMetaDataEntry("definition") != "fdmprinter":