Repair broken loader, since #388#426
Conversation
|
Note that the initialization happens during UI as it requires an active Qt Application instance to exist which does not have to be true during |
Hmmm, I think those two, |
|
It's looking like they create actual instances of Qt object. core/avalon/tools/loader/lib.py Line 96 in 48823f4 That should probably happen within the GUI itself, rather than in conjunction with making database queries. |
It creates actual Qt icons, yes. That's why it needs a QApplication instance. This was also one of those things that I believe is referenced across multiple tools and it's to optimize the loading time of the icons. You wouldn't want do to that in the Basically it's persisting the icons for reuse.
I believe this is actually used across multiple tools/widgets/models, but not too sure. I think this was also one of the reasons we wanted to refactor Referencing #427 |
Oh that's not good. I wonder if everything was lost from that PR? It's possible that when merging 388 that the wrong app.py was picked; merging an older one instead of the current one. Having a look at this now. Which reminds me we need some way of launching tools without a host for debugging and development, something like
No that's true, but there may be a better way to solve this, whilst at the same time making it clear that it is an optimisation rather than functional feature; by using a cache. def data(self, index, parent):
...
if role == DecorationRole:
try:
return self._icon_cache[index]
except KeyError:
icon = heavy_compute_of_qicon()
self._icon_cache[index] = icon
return icon |
This was exactly that. A cache for re-use, but then across multiple tools. Feel free to improve and submit a PR |
Yes, no sorry. I mean an explicit cache; something others can see "ah, that's an optimisation". There is currently no indication that these |
Loader broke with #388, this fixes that.
However, there's reference and initialization to global state happening from within the GUI; that isn't nice. Initialisation should happen during
api.install(), and all state should reside inavalon/__init__.py. Leaving this for now as technical debt.