Archive: Finish page not showing when custom page aborted


Finish page not showing when custom page aborted
Hi

I'm a newbie so hopefully this is an easy one to answer.
If I abort a custom page because I do not want to display it (normally based on a condition), the installation carries on as expected but the Finish page does not appear.
If I "show" the custom form then the Finish Page appears.

Thanks
Niall

Here's a simple example...
(MakeNSIS v2.34)

!include "MUI2.nsh"

Name "test"
XPStyle on

OutFile "test.exe"

Var Dialog

!insertmacro MUI_PAGE_WELCOME
Page custom nsDialogsPage
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"

; The stuff to install
Section Test Section1
MessageBox MB_OK "Section 1"
Sectionend

Function nsDialogsPage

nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog

${If} $Dialog == error
abort
${EndIf}

; Don't want to display this so...
abort
;nsDialogs::Show

FunctionEnd
__________________


Your method seems odd to me...
In your example, you go to all the trouble of creating the page and then use abort to bail out.

Wouldn't it make more sense to just skip over all the page creation stuff if you wanted to abort?
Like maybe try this:

 Function nsDialogsPage
; skip now if you want:
${If} [some condition]
Return
${EndIf}

nsDialogs::Create /NOUNLOAD 1018
Pop $Dialog

${If} $Dialog == error
abort
${EndIf}

nsDialogs::Show

FunctionEnd

Hello

You're absolutely right. I was too busy looking for a technical solution to see my approach was dumb anyway.

Out of interest, is there an explanation as to why an abort would stop the Final page?

Thanks for your help
Niall


As far as I understand calling "Abort" only has a special purpose in the Callback-Functions for built-in pages (pre_function, show_function, leave_function). In those Callback-Functions "Abort" will either prevent the page from being displayed (pre_function) or will force the user to stay on the current page (leave_function). But when calling "Abort" in your custom page function (here "nsDialogsPage"), then "Abort" will have it's normal effect. And that is: Setup has failed, stop execution of script, abort setup! Hence the Finish page won't be displayed...


Hi

From the example I worked on, it would appear that the Abort did not stop MUI_PAGE_INSTFILES and the Sections code from executing, in fact removing the Abort altogether had no effect either way i.e. the display of the final page depended on whether nsDialogs::Show was called or not.
Anyway, I guess it's academic, the best solution would appear to be to include the "Condidion" before the nsDialogs::Create.

Thanks again to all
Niall


Read the docs. It clearly says what "Abort" does, it stops the execution of the script. There are some Callback-Functions where "Abort" has a special purpose and these functions are also mentioned in the docs. Unless explicitly stated, calling the "Abort" instruction will terminated your installer. I don't see any statement like "Calling 'Abort' in your custom page 'creator_function' will skip that page" in the docs. Do you ???


In my last post, I was making the observation that, in my example, "Abort [in the custom page] did not stop [the subsequent] MUI_PAGE_INSTFILES and the Sections code from executing" - behaviour which can be observed by running the code I included.

I subsequently realised that this behaviour is caused by the absense of "nsDialogs::Show".

Calling nsDialogs::Show and then Abort produces the documented behaviour; so the lesson is, don't use "Create" without "Show"!