JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
572 stars 75 forks source link

Non-deterministic registration order for scripts #44

Closed florianfelix closed 4 years ago

florianfelix commented 5 years ago

This seems only to be an issue while developing with reloading (via auto_load.py). When the addon gets registered the normal way in the preferences it seems to always work.

When classes in a file get registered they seem not to be registered in any deterministic order. The Problem occurs when Panels with "bl_parent_id" try to get registered but the parent panel is not registered yet. When repeatedly saving the file (triggering a reload) sometimes it works which seems to suggest the registration order is somehow random. The subpanels also appear in random order inside the parent when it works.

Sample ui panels file: https://gist.github.com/florianfelix/4cfdff72c4c3e4864384e42c19ab082a

Is there maybe already any way to force some kind of registration order on the classes?

florianfelix commented 5 years ago

I fiddled a little with auto_load.py. Mainly replacing sets with lists and sorting classes by name. It seems the frequency of failure is a little bit down. But not solved.

https://gist.github.com/florianfelix/2f7c22c5f9f7d85b37c3bf3568466ef0

JacquesLucke commented 5 years ago

Yeah, I have to update the script to make bl_parent_id work reliably. This is a relatively new thing.

florianfelix commented 5 years ago

Maybe you do not have to. This seems to work: https://gist.github.com/florianfelix/924383d408a7e27fb6ebe2cf1a327842

The last OrderedDict in toposort seems to have doneit

But now it depends on the ordering by classnames which may not be ideal

JoeKingKong commented 4 years ago

Happy new year, I am at the same point right now. Are there any news? Thx

LorenzWieseke commented 4 years ago

You may set the bl_order of the panel to solve this problem. Using this in combination with bl_parent_id didn't work for me though