HaydenDevlin
17th September 2007 15:03 UTC
Problem with the UMUI cancel button not stopping the install process properly
Hello,
I have recently implemented the UltraModern UI into my installer, because it allows the ability to enable the cancel button when installing, and hence to cancel the installation. So now my installer has the cancel button enabled, and when clicked while installing it calls a funstion OnUserAbort, which uninstalls everything that the installer installs (including things that may or may not have been installed at the time of cancellation - deleting things that don't exist is no problem). My problem is that when I click the cancel button, it goes about uninstalling the files, but it seems like some of the installation section must continue or something, because not all of the files are cleared up. The uninstall method is fine, so I think that it's something to do with the cancel click code maybe not stopping the install code properly so some installation occurs while uninstalling... can that happen? That's a bit of a guess though! Can anyone shed some light onto why this might be happening?
Thanks in advance for any help,
Hayden Devlin
Kayl712
17th September 2007 17:39 UTC
I think there is a good reason why this button is disabled in the first place with current NSIS versions.
When using UMUI I noticed that :
- enabling the abort warning, you can notice that the warning (launched from UMUI .onUserAbort callback) is non-blocking and that sections are still processed in background while the message box is displayed
- if using an abort page, file keep being installed when this page is displayed since it calls Abort from the .onUserAbort callback
The section processing seem to be in a different thread and can not be stoped by the user if the .onUserAbort did not return. Therefore no processing must be done in this callback.
In the .onUserAbort you must only set a flag to true, let the callback return without calling Abort and in your .onGuiEnd callback, rollback your changes.
At least that's what I'm using.
Note : of course you have to modify UMUI to have a function of your own called from the UMUI callback .onGuiEnd
Since I'm also concerned by this problem, I am opened to any other solution.
HaydenDevlin
17th September 2007 18:53 UTC
I have tried your solution, as you are right and the problem is clearly one of threading, but it didn't seem to stop the problem. I now have a onGuiEnd method that is called when the gui closes, and uses a variable to determine whether it should clear up the files or not, and clears them up if it needs to. But the thread that installs the files still doesn't seem to actually stop running, even when the GUI is no longer visible and the thread should have stopped, it still seems to result in some files being left from the installation, in the same way as I described earlier. Does anyone know if there is a good way to actually stop a thread from running? Or am I doing something wrong here with this method?
Thanks for any help,
Hayden Devlin