Archive: InstFiles window doesn't paint propertly in .onInstFailed


InstFiles window doesn't paint propertly in .onInstFailed
I am writing a fairly large and complicated installer.
When the installation fails, I roll back installed components in the .onInstFailed callback function.
The problems I am seeing are:
a) DetailPrint no longer prints to the Listbox but only to the Status bar.
b) NSIS seems to stops painting its window, i.e., the NSIS window turns gray, except for the Status bar message, which keeps getting updated.

What have others here done for rolling back incomplete/failed installations? Have you also seen these problems?


.onInstFailed was not created for this purpose. It's just for showing a simple message box or writing to a log, but it's not for huge operations. It's called within the message loop and therefor the window doesn't redraw and DetailPrint doesn't work as expected.

Aside from using another instfiles page to do the roll-back operation I have no other ideas at the moment. This idea will not work when the user aborts the installation if a file can be overwritten but you can remove the cancel button with the new AllowSkipFiles command.


Oh, so there's nothing preventing me from creating another Instfiles page?
Cool- I'll try that.


Hmmm... not as easy as I thought.
Are there any examples out there of multiple InstFiles pages?
I see it is on the "ToDo" list.


I think I wrote one once, but I can't find it right now. I'll just give you the basic idea for your task. In case you need to abort set a variable to a certain value. On the pre function of the second instfiles page read the variable and if it's not set skip the page. If you haven't skipped the page loop through all sections and disable all of them and enable just the rollback function:

Section /o "" rollbackSection
SectionEnd

#...

StrCpy $0 0
loop:
SectionSetFlags $0 0
IntOp $0 $0 + 1
IfErrors 0 loop

SectionSetFlags ${rollbackSection} ${SF_SELECTED}


This will cause nothing but the rollback section to execute. In case you need the other sections' flags to remain so you can know what to rollback you should convert their SF_SELECTED flag to something that's not used such as 4096 (a safe distance from the last flag).

Yes, that's essentially how I was thinking of implementing it.
I was just hoping there was an easier way, e.g., maybe have a Section called Rollback the way we have a Section called Uninstaller, which can be automatically invoked by the installer if the installation fails.


Not yet :)


Looks like the second InstFiles page method isn't going to work after all.
Here are the problems I found:
On the first InstFiles page, if an error occurs and I call Abort, the "Back" & "Next" buttons get disabled and the "Cancel" button gets enabled. Clicking the Cancel button closes the installer.
Not good. :(

So, I changed it. Now, if an error occurs, i don't call Abort but set a flag instead. However, now nsis thinks that setup succeeded, so it shows a message saying "Setup Complete" and the Next button label changes to "Install". When I click "Install", its label changes to "Next". When I click "Next", the second InstFiles page starts. Now the Rollback section gets called OK but the problem is that the progress bar is maxed to 100% and doesn't move any more.
Even worse. :cry:

I'm still open to ideas on how to implement installation rollback. :confused:


Aside from the progress bar maxing out very quickly (which is a bug that have already been fixed in the latest CVS version of now :)) the attached file does exactly what you want.