mzScript threaded & VTray - Problems Thread last updated on 2004-07-08 14:33:42

Posted by member 103440 on 2004-07-08 04:28:39

Hi!
I want to use mzScript threaded to improve performance on my theme. I wasn't using threaded before and the script for resizing the systray and taskbar worked perfectly! Now I'm having problems :(. I (always) load VTray after mzScript for the onAdd/onDel bangs to work.
What can be the problem?
When the theme starts, it seems that the !SystrayIconAdded isn't working at all, but after that if i add or remove icons from the systray or calls the bang manually it works fine.... very odd ... i think.
I have tryed changing module order and threaded status in VTray but no luck :(
Does anyone know a solution for this?

The script for counting the icons on systray is the same from Austerity!

I'm using:
- VTray v1.10
- mzScript v0.9 beta 12
- Taskbar3 v0.306 alpha 4

Posted by member 37809 on 2004-07-08 10:01:19 link

Have you tried to !(net)reloadmodule VTray and Taskbar3 from mzscript *script start's?

Posted by member 99 on 2004-07-08 13:02:40 link

scripting + threading = race conditions.

If you're not using NetLoadModule, do so, or load those other modules from *script start like tnl suggests. Actually, I'm not sure whether or not !reloadmodules from a threaded module will force things to load sequencially... but at least you'd know that they won't load until mzscript is done. NLM forces things to load in order, even if NLM itself is threaded (er, I think).

Otherwise, make sure the script will work even if it is called too late. eg, if 3 icons are added quickly, your OnAdd script may be called (3 times) only after vtray's vars have been updated for all of them. Similarly for any bangs you call from inside mzscript. (except things that stay entirely within mzscript, like !varset)

Order should still be the same though, so if you get an add and a del, the OnAdd and OnDel scripts should be executed in order, but the tray's vars may have already been updated for OnDel by the time OnAdd gets executed.

Posted by member 103440 on 2004-07-08 14:33:42 link

Hi!
Thanks @Tnl and @RabidCow for your suggestions.
After writing this thread I tried to (net)load VTray on "*script start" and it worked better :) but not good enough :( .I loosed the counting of some icons, and when some icons where removed the script worked totally wrong!

-- 1st Case --
So I wrote a new script of my own with a different approach. Instead of using "TaskBarGrow" and "TaskBarShrink" each time a icon was added, I used the %#vTrayCurrentIcons%# and calculated the entire vTraySize. Now it works fine. Here is the script i used:

*Script bang !VTrayChange
*Script exec !VarSet IconNumber "0"
*Script exec !VarAdd IconNumber %#vTrayCurrentIcons%#
*Script exec !IfEval ("%{IconNumber}" = "0") {!TaskbarSize $TaskBarWidth$}
*Script exec !IfEval ("%{IconNumber}" < "1") {!TaskbarShrink "19"}
*Script gotoif ("%{IconNumber}" > "1") SizeCount_lbl
*Script exit
*Script label SizeCount_lbl
*Script exec !VarSet TraySize "0"
*Script exec !VarAdd TraySize "19"
*Script label start
*Script exec !VarAdd IconNumber "-2"
*Script gotoif ("%{IconNumber}" |minus or equal| "0") end
*Script exec !VarAdd TraySize "18"
*Script goto start
*Script label end
*Script exec !TaskbarSize %#TaskBarWidth-%{TraySize}%#
*Script ~bang


"|minus or equal| -> I couldn't put the correct code here, after many edits found the solution... weird bug in this forum"

-- 2nd Case --
After a while i realized that there was another exported variable from vTray -> $vTrayCurrentWidth and i wrote another script (much more simpler ;)) to do the calculation, here it is:

*Script bang !VTrayChangeLite
*Script exec !TaskbarSize %#TaskBarWidth-vTrayCurrentWidth+2%#
*Script ~bang


Before inserting the above script on the onAdd/Del commands from vTray, i tested it manually from LSXCommand and it worked perfectly. But when i switched for this script to the onAdd/Del commands from vTrays and recycled... nothing happened! Very strange indeed! But if i call it manually after the LiteStep Recycle/Loading there is no problem! I put vTray to load in "*script start" and no good either!

Right now, i want to known where the problem is… "vTray" or "mzScript threaded"? Or both!
I will sticky with the first case and do some more testing.
(I don't need to load vTray on "*script start" to work correctly on the first case!)