Archive: MUI + Messagebox plugin - Bug?!


MUI + Messagebox plugin - Bug?!
Hello world,

I came across the following bug when using MUI and the messagebox plugin: When I define my own MUI_CUSTOMFUNCTION_ABORT function and use messagebox::show in it, then an additional (undesired) button is shown when "Cancel" is pressed for the first time.

I have stripped down the error to the following small example. I found that...
a) When you press "Cancel" for the first time, an undesired third button is shown.
b) All subsequent uses of the Cancel button show only the "Yes" and "No" buttons (as desired).
c) When I use msssagebox:show in the "Section" instead of the custom function, the bug does not show up.

Is this a known bug or am I doing something wrong? What can I do to resolve the issue?

Jens

Name "Test"
OutFile "Test.exe"
!include MUI.nsh
!define MUI_CUSTOMFUNCTION_ABORT MUI.onUserAbort
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_LANGUAGE English

Section
SectionEnd

Function MUI.onUserAbort
messagebox::show MB_DEFBUTTON2 "" "" "Really cancel?" "Yes" "No"
pop $0
StrCmp $0 "1" +2
Abort
FunctionEnd

you need to ensure that that stack is clear before calling the messagebox function (push/pop combination from what i remember). one day i may eventually re-write the lost code of that plugin so as not to have that issue (inbetween all of my winamp duties)

-daz


you need to ensure that that stack is clear before calling the messagebox function
How would I do that best? In my example, none of my own code is executed before the plugin is called (only NSIS and MUI code). So how can I save all current stack values and restore them afterwards - all without exactly knowing how many values are on the stack?
one day i may eventually re-write the lost code of that plugin so as not to have that issue (inbetween all of my winamp duties)
Pleeeeaaaaase do so. Winamp duties will surely happily wait some time in favor of NSIS... ;)

Messagebox Plugin - Reproducible Error
Hello world,

I learned that the messagebox plugin requires an empty stack before calling messagebox::show, so I wrote two auxiliary macros _MSGBOX_CLEAR_STACK and _MSGBOX_RESTORE_STACK to to the job. But now I frequently get an "unhandled Win32 exception" if I use the plugin in the MUI_CUSTOMFUNCTION_ABORT function.

I have stripped down the issue to a small test script that is attached to this posting.
Could somebody please be so kind to have a look at it and see if you can reproduce the error?

1. Run the compiled "Test.exe".
2. Proceed to the second page (directory selection).
3. Press "Cancel" and confirm with "Yes".

At this point the Visual Studio debugger pops up claiming an unhandled Win32 exception. This does not always happen, but still about every second time I run the installer. The same thing happens on at least two other computers.

My system:
Windows XP SP2 with latest patches, NSIS 2.31, Visual Studio 2005 SP1 installed (that's why the debugger pops up when the error occurs).

I am not quite sure if it's a bug in the plugin, or in MUI itself, or if it's just me doing something wrong. Any helpful comments are welcome.

Jens