Archive: wierd nsDialogue crash issue


wierd nsDialogue crash issue
I'm having a wierd issue where, in the SelectFolderDialogue, if i try to create a new folder (using the supplied button), and select that folder, the proceeding call to SetWindowText crashes my installer...

any ideas?

#I've created a custom page, here's the loader function for it:

Function customDirectoryDlg
nsDialogs::Create /NOUNLOAD 1018
Pop $0
${NSD_CreateDirRequest} 0 20u 80% 15u "$INSTDIR"
Pop $DIR_EDIT
${NSD_CreateButton} 82% 20u 40u 15u "Browse..."
Pop $DIR_BUTTON
${NSD_OnClick} $DIR_BUTTON DirButtonOnClick
nsDialogs::Show
FunctionEnd

# and here's the ButtonClick event function:
Function DirButtonOnClick
Pop $0 #HWND
nsDialogs::SelectFolderDialog /NOUNLOAD "Select folder" "$INSTDIR"
Pop $0
# in the SelectFolderDialog, if you create a new folder,
# and select that new folder, the following line will
# crash the installer
System::Call `user32::SetWindowText(i $DIR_EDIT, t "blah")`
FunctionEnd


What are the crash details?


I get a Microsoft dialogue with the following buttons as options:

"Debug"
"Send Error Report"
"Don't Send"

There is also a binary dump of the exe and a list of dll/modules (i suspect) in their various states at the time of the crash.

Is this any help? Is there any other information you need?


Any details at all would help as currently I can't reproduce the problem. An installer that reproduces this or, even better, a complete and minimal script, would also help.


I'm attaching a small script that duplicates the problem.
I narrowed the problem down to the interaction between my OnClick function and my OnChange function.

in my OnClick function, the user selects the folder. I post this new folder string to my Edit box (for which there is an OnChange event). the OnChange event gets called, calls GetWindowText, which appears to succeed (the final MessageBox gets called with the appropriate data). Then the installer crashes.

I'm wondering if i'm butchering the stack? Popping when i shouldn't be? not popping when i should be?

thanks for your support in this!
-chris


That script did reproduce the problem. The problem appears to be calling the System plug-in in gxDirEditOnChange which is triggered by the call to SetWindowText in gxDirButtonOnClick. Because /NOUNLOAD wasn't used in the GetWindowText call, the System plug-in was unloaded while it was still processing the SetWindowText higher up in the stack.

This is an issue I haven't considered when I introduced function callbacks for plug-ins. I am unsure of the best solution for this.

The immediate solution for your problem is using /NOUNLOAD on line 36.


Interesting.
that solution works, and is certainly easy enough.

Thanks for your help Kichik :)

-chris


Re: wierd nsDialogue crash issue

Originally posted by mordekai
I'm having a wierd issue where, in the SelectFolderDialogue, if i try to create a new folder (using the supplied button), and select that folder, the proceeding call to SetWindowText crashes my installer...

any ideas?
Interesting ... I've just been doing the same thing. It's something I'd have expected to find in the NSIS examples and it hurts to find it isn't quite the no-brainer it should be!

<snip>
# and here's the ButtonClick event function:
Function DirButtonOnClick
Pop $0 #HWND
nsDialogs::SelectFolderDialog /NOUNLOAD "Select folder" "$INSTDIR"
Pop $0
# in the SelectFolderDialog, if you create a new folder,
# and select that new folder, the following line will
# crash the installer
System::Call `user32::SetWindowText(i $DIR_EDIT, t "blah")`
FunctionEnd
System::Call seems like a sledgehammer to crack a nut, here, though. Why not just use SendMessage? I have something like this:


Function doBrowse

pop $0 ; get control hwnd off stack

nsDialogs::SelectFolderDialog /NOUNLOAD "Select Install Folder" "C:\MyApp"
pop $0

${If} $0 == "error"
Return
${EndIf}

SendMessage $InstDirCtl ${WM_SETTEXT} 0 "STR:$0"

FunctionEnd

Note the all-important "STR:" in front of the lparam argument.

This will be fixed in the next version - 2.42.