Archive: nsDialogs checkbox lose its hadle


nsDialogs checkbox lose its hadle
Hi


In the custom page I create check box (among other controls) and keep its handle


${NSD_CreateCheckBox} 0 $3 50% 6% "${RESTORE_DB_CHECKBOX_TEXT}"
Pop $checkBoxRestoreDB
;Set default
${NSD_SetState} $checkBoxRestoreDB ${BST_CHECKED}
${NSD_OnClick} $checkBoxRestoreDB DisplayOrHideAdminUserAndPass


In the Page leave function there is some logic which might Abort of the page leave and keep displaying the page.

Under some flows (depend of the user selections) the variable $checkBoxRestoreDB that holds the check box handle have another value - the name of installer single section

Renaming the section, and recompiling - and now the variable has the new section name.
Obviously I do not do it myself - setting this variable to hold the section name. as all I have changed is:

Section "Server Filess" SecServerFiles


it took some time to find a workaround which is even weirder

I just added a log print of the handle
If I still write the line without the handle - i have problem again

The LogPrint macro writes a line to the log file


!insertmacro LogPrint "ConnectAndCheckIfDataBaseExist 3: check box handle: $checkBoxRestoreDB"

!macro LogPrint msg

;Open log file for append
LogEx::Init "$LogFileName"

;Write log message
LogEx::Write true true "${msg}"

;Close
LogEx::Close

;write message to the Log file created by the NSIS special build (LogSet)
LogText "${msg}"

!macroend



This all thing looks very weird to me and I'm sure there is something here which I miss.
Anyone?

tx

Oren

Well you state that you're not touching the variable after you pop it, but that is still the most likely explanation - something you do (or a function/macro does) tells NSIS to store something else in the variable. Please create for us a minimal script that shows this problem. Chances are, you'll find the cause of the problem in the process. If not, it will allow the devs to find out what's happening under the hood.


Maybe you're right
yet,
how come simple logging the handle makes all good?
and another,
the section name - where did it come from?

I will try to recreate it within a small script

tx


Once you have left the nsDialogs page, its controls are destroyed and the handle is no longer valid. You should not be using that variable anywhere else unless you have specifically set it to something else. Otherwise it's just a handle, i.e. an integer value.

Stu


I am aborting (i.e call the Abort function) the page_leave function.
As I understand - this is not leaving the page.
The creator_page function is not called again and all variables have the proper value.

Am I wrong?


Sorry when you mentioned sections I assumed you were reusing the variable there. But no, the handle is still valid in the leave function. Any time after then, it should still have an integer value.

Stu