ZeroBraneStudio icon indicating copy to clipboard operation
ZeroBraneStudio copied to clipboard

Determenistic order of load plugins.

Open moteus opened this issue 7 years ago • 6 comments

Now I have few plugins which extend menu. And menu items can change order from run to run zbs. Does ZBS order plugins by file name?

moteus avatar Jan 19 '18 08:01 moteus

No, it loads them in the same order as returned by "pairs", which is not deterministic. I thought about sorting plugins before loading, but I'd not want plugins to depend on the order, as it may have strange effects and unintended consequences. Is there any reason other than the order of the items on the menu being different between runs?

pkulchenko avatar Jan 20 '18 02:01 pkulchenko

@moteus, any further details on this? I'm tempted to close it, but would like to have more information behind the request before I do.

pkulchenko avatar Jan 25 '18 19:01 pkulchenko

Sorry I thoght that i unswer on this. Yes I whant only determenistic menu order created by plugins. I think it is quite important

moteus avatar Jan 26 '18 07:01 moteus

@moteus, I got that; I was looking for more details on why you think it's needed.

Is there any reason other than the order of the items on the menu being different between runs?

pkulchenko avatar Jan 26 '18 17:01 pkulchenko

I was looking for more details on why you think it's needed.

I add menu items to popup menu and I use these items quite often. So when I need invoke one of menu I make right mouse click and whant to be able choose say last menu item or second from end whithout reading menu text. And in fact order is not not as importan. But just whant this order keeps same. Until I add new plugin with new menu item.

moteus avatar Jan 27 '18 18:01 moteus

I looked at it again and recalled why I thought it was problematic. Deterministic order requires sorting and caching the results to order the keys, but it's not clear when to invalidate the cache results and it's likely to be wasteful to resort every time a hook is called. It can probably be done after onRegister and onUnregister events, but even that is not a full guarantee.

pkulchenko avatar Feb 03 '18 19:02 pkulchenko