mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 22:54:01 -06:00
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:
parent
2a39d81a3c
commit
6d3fed8f52
9 changed files with 52 additions and 23 deletions
|
@ -30,9 +30,10 @@ class ContainerNode:
|
|||
def getChildNode(self, child_key: str) -> Optional["ContainerNode"]:
|
||||
return self.children_map.get(child_key)
|
||||
|
||||
def getContainer(self) -> "InstanceContainer":
|
||||
def getContainer(self) -> Optional["InstanceContainer"]:
|
||||
if self.metadata is None:
|
||||
raise RuntimeError("Cannot get container for a ContainerNode without metadata")
|
||||
Logger.log("e", "Cannot get container for a ContainerNode without metadata.")
|
||||
return None
|
||||
|
||||
if self.container is None:
|
||||
container_id = self.metadata["id"]
|
||||
|
@ -40,7 +41,8 @@ class ContainerNode:
|
|||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
container_list = ContainerRegistry.getInstance().findInstanceContainers(id = container_id)
|
||||
if not container_list:
|
||||
raise RuntimeError("Failed to lazy-load container [%s], cannot find it" % container_id)
|
||||
Logger.log("e", "Failed to lazy-load container [{container_id}]. Cannot find it.".format(container_id = container_id))
|
||||
return None
|
||||
self.container = container_list[0]
|
||||
|
||||
return self.container
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue