- NSIS Discussion
- wierd nsDialogue crash issue
Archive: wierd nsDialogue crash issue
mordekai
29th January 2008 17:31 UTC
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
kichik
29th January 2008 18:52 UTC
What are the crash details?
mordekai
29th January 2008 19:04 UTC
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?
kichik
29th January 2008 20:24 UTC
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.
mordekai
29th January 2008 20:55 UTC
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
kichik
29th January 2008 21:18 UTC
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.
mordekai
29th January 2008 21:49 UTC
Interesting.
that solution works, and is certainly easy enough.
Thanks for your help Kichik :)
-chris
Daniel James
17th February 2008 15:50 UTC
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.
kichik
29th November 2008 22:34 UTC
This will be fixed in the next version - 2.42.