mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 22:54:01 -06:00
Make ContainerTree singleton but construct in run() of application
We want to make sure that this tree is constructed during start-up after all containers have been registered, so we call getInstance() there once. If you need the tree before that, the tree will not yet have been filled and you won't get complete information, so you'd need to listen for updates. The singleton is there so you don't need to go via CuraApplication. Contributes to issue CURA-6600.
This commit is contained in:
parent
65360c31ef
commit
e106692165
2 changed files with 12 additions and 0 deletions
|
@ -14,6 +14,14 @@ from typing import Dict
|
|||
# The tree starts at the machine definitions. For every distinct definition
|
||||
# there will be one machine node here.
|
||||
class ContainerTree:
|
||||
__instance = None
|
||||
|
||||
@classmethod
|
||||
def getInstance(cls):
|
||||
if cls.__instance is None:
|
||||
cls.__instance = ContainerTree()
|
||||
return cls.__instance
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.machines = {} # type: Dict[str, MachineNode] # Mapping from definition ID to machine nodes.
|
||||
container_registry = ContainerRegistry.getInstance()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue