getavalon / core

The safe post-production pipeline - https://getavalon.github.io/2.0
MIT License
218 stars 49 forks source link

Remove global state and initialisation from Loader #427

Open mottosso opened 5 years ago

mottosso commented 5 years ago

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.

https://github.com/getavalon/core/blob/48823f4d6369b9648e74709d2f63d69b89a8bcf8/avalon/tools/loader/lib.py#L87-L99

What did you expect?

In addition, these functions are only used in one place.

Additional context See https://github.com/getavalon/core/pull/426

BigRoy commented 5 years ago

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.