Archive: How to 'Quit' from a custom page's leave function!?


How to 'Quit' from a custom page's leave function!?
Hello,

I am using the latest nightly snapshot of NSIS and have run into something. I want to kill or 'Quit' an installer from a custom page's leave function.

However, as far as I can see, the 'Quit' statement when executed from a custom page's leave function does NOT exit the installer. Instead, it behaves as if I had written 'Abort' instead. I.e. it causes the installer to remain on the current page.

Is this the correct behaviour for the 'Quit' statement in this context? If so, how can I force the installer to exit from a custom page's leave function?

Thanks in advance. :)

(BTW to reproduce the issue I am describing you can download the attached modification of Contrib\InstallOptions\test.nsi - only lines 70 and 71 are new, the rest is the original script.)


Just a sort of mini follow-up...

Actually what I really want to do is have the custom page's leave function call another function which causes the installer to exit. The problem is exactly as described earlier though, the installer won't quit.

The leave functio calls the quitting function just fine, but the isntaller doesn't quit and instead just sits on the current page.

Once again, I've attached a straightforward modification of Contrib\InstallOptions\test.nsi.

Thanks again. :)


Why not have the leave function set an exit code in a register (or on the stack) then the function that creates the custom page can check to see if the installer should quit?

Here is a modified version of your script that I hope does what you want.


pengyou: Thank you, your suggestion does achieve what I want. :) I will use this approach unless a more direct solution emerges.

Ideally I would like to be able to use 'Quit' directly (the documentation for the command and the documenatation for page callbacks does not indicate that Quit cannot be used in a custom page's leave function) or something along those lines.

I find it interesting that 'Quit' behaves as expected when used in a page creation function and then differently in the leave function.

Thanks again for your suggestion pengyou. :)


Glad I was able to help!

Custom page "leave" functions only appeared a few months ago and are a big improvement. I find them very useful when validating user input, even if there are a few limitations (so far I've not come across anything major).


I agree pengyou, NSIS has become so much better over the past few months that it almost cannot be believed. :D

I've been toying with my installer and I got it to commit suicide... It was a little more complex than I thought though because the Suicide/Quit function is being called from *several* points in the script. So I needed to add some flags to check if it was called from the custom page's leave function, in which case it sets an exit code which is then checked in the custom page's create function. This stuff doesn't happen of course for all other calls to the Suicide/Quit function.

However, the Suicide/Quit function is *supposed* to be a cleanup function: do some things, then terminate the installer with extreme prejudice - I don't want control to return from the Suicide/Quit function under any circumstances - this is why I added a 'Quit' statement to it on the first place.

So is it possible to 'Quit' or somehow terminate an installer from a function called from a custom page's leave function? ;)

(An example of what I'm trying to do is in the attachment to the second post in this thread. The 'Suicide' function *has* to be called from the custom page's leave function, and the 'Suicide' function has to Quit the installer, it cannot return control. :|)


Quit should work from custom page's leave function. I'll check it out.


Thank you Kichik, it's nice to know that 'Quit' is supposed quit the installer even from a custom page's leave function.

I greatly appreciate that you are willing to look into this matter, I can't imagine what the demands on your time must be like.

Thanks again. :)


Hi,

This problem is fixed now, check CVS later

Ramon


Thanks Ramon, I got the latest snapshot and it's working great now. :D

Once again, many thanks. :)