Go Back   Winamp Forums > Developer Center > NSIS Discussion

Reply
Thread Tools Search this Thread Display Modes
Old 5th February 2010, 19:01   #1
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
NSDialogs::NSD_GetText intermittent failure and crash with 8192-char build

I'm running into an odd problem here where NSD_GetText will return what appears to be an empty string from an edit control (NSD_CreateText) intermittently.

I.e. on my installer's startup, where I've got an interactive feedback through an NSD_OnChange, it will very often fail.. I'll enter some gobbledygook into the edit control and suddenly - randomly - it'll start working. After that it'll tend to keep working, but every once in a while it'll break again as well and once again it returns an empty string.

I am using the 8192-character version of makensis, and this seems to be the culprit somehow; reverting to the regular build solves the issue - but creates a new one

I can't share the actual installer code, but here's a sample that will replicate the behavior - albeit less severely so.

PHP Code:
!include "MUI2.nsh"
!include "nsDialogs.nsh"

OutFile "test.exe"

Page Custom test

Var dialog
Var editcontrol
Var label
Var hwnd

Function test
    nsDialogs
::Create 1018
    Pop $dialog

    
${NSD_CreateText031008"Testing"
        
Pop $editcontrol
        
${NSD_OnChange$editcontrol editchanged

    
${NSD_CreateLabel01210070"Testing"
        
Pop $label

    nsDialogs
::Show
FunctionEnd

Function editchanged
    Pop $hwnd
    
${NSD_GetText$hwnd $0
    
${NSD_SetText$label $0
FunctionEnd

Section
SectionEnd

!insertmacro MUI_LANGUAGE "English" 
Tests to run:
1. Enter some text. It should get replicated in the label below the edit contol.

2. Copy the text and paste it a bunch of times - eventually (at 256 characters), the label will not show the text anymore.
At this point, if you erase your text, the label may either update again or it will stay empty.
( in the standard build, you can enter well beyond 256 characters without problem. )

3. Paste your text a whole lot more - eventually, the installer will simply crash to desktop.

Unfortunately this is not exactly the same scenario as in my actual installer - as it has far less than 256 characters in it; but I'd imagine the problems are related if not the exact same in origin.

Thoughts? Thanks in advance!
Animaether is offline   Reply With Quote
Old 6th February 2010, 15:31   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,337
I can't reproduce this with either builds. Can you find a scenario that's easier to reproduce?

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 6th February 2010, 22:34   #3
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
I was hoping that was the easiest reproduction case - never fails to fail here :\

Let's try with this, though...
PHP Code:
!include "MUI2.nsh"
!include "nsDialogs.nsh"

OutFile "test.exe"

Var InstallDir

Var dialog
Var hwnd
Var null

Var NSD_InstallDir
Var NSD_StatusLabel

Page Custom page
.settings


Function page.settings
    
!insertmacro MUI_HEADER_TEXT " Installation settings" " Some more text goes here..."

    
nsDialogs::Create 1018
    Pop $dialog

    
${NSD_CreateLabel33258"&Installation folder: "
        
Pop $null

    
${NSD_CreateText293638"C:\Program Files\Test\Test 2"
        
Pop $NSD_InstallDir
        
${NSD_OnChange$NSD_InstallDir page.settings.installdir.onchange

    
${NSD_CreateButton92358"..."
        
Pop $hwnd

    
${NSD_CreateGroupbox06010039""
        
Pop $null
    
${NSD_CreateLabel3669431""
        
Pop $NSD_StatusLabel

    nsDialogs
::Show
FunctionEnd

Function page.settings.installdir.onchange
    Pop $hwnd
    
${NSD_GetText$hwnd $InstallDir
    MessageBox MB_OK 
"$$InstallDir = '$InstallDir'"
    
${NSD_SetText$NSD_StatusLabel "'$InstallDir'"
FunctionEnd


Section
SectionEnd

!insertmacro MUI_LANGUAGE "English" 
This is slightly more akin to the actual installer I'm working on - basically that's an installation path bit with browse button and whatnot, and I'm interactively checking whether the path is malformed or not, etc. That code isn't included here, but you get the idea.

Build this with NSIS 2.46 base install + makensis v2.46 NSIS_MAX_STRLEN=8192.

Upon execution, nothing particular should happen. Now add/remove text from the path. You should get a messagebox, and a status label gets updated.
On the very first character I enter, that messagebox and label shows me that the value that was retrieved with NSD_GetText appears to be empty, displaying ''. The second character is okay.

The aforementioned bits still apply, though - it intermittently fails again. Easier to test after removing the messagebox (which is just there to check whether the problem was in gettext or settext).

Without fail - the 1024-character default build works just fine even on the first character changed.
Animaether is offline   Reply With Quote
Reply
Go Back   Winamp Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump