tags:

views:

33

answers:

2

Hi, I'm stuck on this. I have this callback function at the bottom of a subscript (.nsh) file. (As you can see I'm using LogicLib):

Function InstallFoo
MessageBox MB_OK "Within InstallFoo function"
${If} ${FileExists} "$EXEDIR\Modules\foo.zip" 
MessageBox MB_OK "foo.zip found, do install it!"
nsisunz::Unzip "$EXEDIR\Modules\foo.zip" "$INSTDIR\Foo"
${Else}
MessageBox MB_OK "No foo.zip found. Do nothing"
${EndIf}

MessageBox MB_OK "End reached"
FunctionEnd

Everything works exactly as I want it to when the 'foo.zip' is present, but when it isn't, the installer crashes, and I really can't understand why.

I would expect it to also be able to handle when the 'foo.zip' is not found, that is by doing nothing. What happens now is that the installer crashes with "setup.exe - Application Error, The instruction at "some-address" referenced memory at "some-other-address". The memory could not be "read".

I have the same type of code within sections in my scripts and it works fine there, whether zip-files present or not. It's just in this callback function it doesn't work, so I'm starting to think it has something to do with it being a callback function.

In the 'foo.zip file not present' - case I get the following MessageBoxes: "Within InstallFoo function" "No foo.zip found. Do nothing" "End reached"

And then the crash. I have a MessageBox printout within the section where the callback was called from also, that is, the first thing to happen after the return from the callback function, but it never gets there. Note, as soon as the foo.zip is there everything works just fine!

Does anyone have any idea of what I might be doing wrong here?

A: 

So I now discovered that if I do like this:

Function InstallFoo
MessageBox MB_OK "Within InstallFoo function"
${If} ${FileExists} "$EXEDIR\Modules\foo.zip" 
MessageBox MB_OK "foo.zip found, do install it!"
nsisunz::Unzip "$EXEDIR\Modules\foo.zip" "$INSTDIR\Foo"
${Else}
MessageBox MB_OK "No foo.zip found. Unzip another file (which exists)"
nsisunz::Unzip "$EXEDIR\Modules\bar.zip" "$INSTDIR\Bar"
${EndIf}

I don't get the crash (provided bar.zip does exist)! Can anyone explain that? The only thing I get out of it is that after a failed file lookup in a callback function, if 'messing' with the memory we'll be fine..?? But if not doing anything to memory installer will crash..?

I'm confused and would really appreciate any help in solving this...

Mini-Me
A: 

It seems to me I get the crash whenever nothing's done within the callback function.

Is it that NSIS allocates some memory for the callback function, and if it's not used we get the crash..?? Weird.

Mini-Me