I am using NSIS 2.12
when using callback function in system plug in,
sometime the callback function will be called even
when the host function (the one uses the callback)
already returns.
The callback support in system plug in is truly
wonderful. But the stack manipluation codes are too
complicated for me. I failed to trace out the prblem.
I got some rough idea though. I suspect that the
problem is when the host function returns, the plug
in doesn't properly prepare the return value for the
callback function (i.e. explicitly clear the
old "callback#" content).
I include an example script to show this problem. I
uses the sample code from the document of system plug
in. But instead of using stack, I use a rarely
touched $9 to hold the return of Callback. After
running the script, and see the details, you will
find that the last two messages are duplicates, thus
proving that there is a redundant callback. If you
insert "StrCpy $9 0" before returning from callback,
the problem is fixed.
sample script to recreate the problem
Logged In: YES
user_id=584402
Seems to me that System simply doesn't clear the output
variable of the callback, if the callback isn't called. This
causes $9 to remain as "callback1" and so the loop code is
executed again. Once the callback is called again, the value
on the stack (1) is copied to $9 because there are no more
callback calls. With the stack example of the documentation,
$0 gets the return value of EnumChildWindows and so the loop
code isn't executed again.
I've updated the documentation to say the callback output
variable should be cleared. The diff should be available in
a couple of hours at:
http://cvs.sourceforge.net/viewcvs.py/nsis/NSIS/Contrib/System/System.html.diff?r1=1.6&r2=1.7
It doesn't seem to me like there's some hidden bug in System
in this case. If it was creating two callbacks instead of
one by mistake, it wouldn't have worked with the stack as well.
Any comments or can this be closed?