Remove global state and initialisation from Loader
Opened this issue · 1 comments
What happened?
The loader is creating and maintaining its own global state in conjunction with making database queries and creating Qt widgets at the same time, using an overly magical function without return value.
core/avalon/tools/loader/lib.py
Lines 87 to 99 in 48823f4
What did you expect?
- State should be initialized during
api.install()
(and the associated host-install) - All state should reside in
avalon\__init__.py
, where it can be cleared onapi.uninstall
to avoid memory leaks
In addition, these functions are only used in one place.
- Single-use functions should be merged with where they are used - reference
Additional context
See #426
For clarification, this is not a Loader-only state but is a global state used across multiple apps. That should be more clear after #440 being merged as it resolves the cross-referencing/importing across multiple tools.
After that merged this code will be found in avalon.tools.lib
and the issue will still be open and relevant.
Additionally what is important to understand is that this state is solely a cache. As such, it should be cached where relevant as opposed to being a global state. E.g. it should be found inside a Model that caches its data or something similar.