Archive: weird group/section behaviour + fixed bug


weird group/section behaviour + fixed bug
Hi,
I'm creating an installer on NSIS (not my first one!) and I have a very strange problem: on the componement pageI select a group, then I push the back button and then I go back to the components page. And there all the sections under the group have moved to the group !
Of course I checked if there was no mistakes or typos in the sections and groups but nothing... Is it a known bug ?
I'm using the latest NSIS release BTW.
Thanks

Alex

PS: another bug found but fixed : after I disabled a section in an .onMouseOverSection function, the post section is never executed... but no errors during install time... I fixed this by updating the section to read-only and everything is back to normal.


It would be good if you post a minimal example for both issues you're referring as for the 1st part of your post would be clear what you mean and for the 2nd what exactly you're doing in .onMouseOverSection (probably you confuse this callback with .onSelChange)


ok I try to explain in a better way the problem:
User chooses a directory in a custom page, if no path is selected one section of the component page is disabled.
As the define of a section is created after the component page I cannot disable the section before the component page. So I chosen to test if I have to disable the section each time something happen on the component page. but section_off makes nsis buggy as I said earlier and only changing the section to read only works.


Still you're not giving a minimal example that would help...
Anyway, is it something like the following that you're trying to achieve?

showinstdetails show
outfile 'test.exe'
Installdir "$PROGRAMFILES\My Application"

var user_def

!include sections.nsh

page custom customcreate customleave
page components
page directory
page instfiles


sectiongroup /e "Main Installation" grp1

section "Application" sec1
sectionin ro
setoutpath "$INSTDIR"
detailprint "installing application"
sleep 300
sectionend

section /o "Documents" sec2
setoutpath "$INSTDIR\Documents"
detailprint "installing documents"
sleep 300
sectionend

section /o "Examples" sec3
setoutpath "$INSTDIR\Examples"
detailprint "installing examples"
sleep 300
sectionend

sectiongroupend


section "User Defined" usr1
;SectionIn ro
setoutpath "$user_def"
detailprint "installing user defined"
sleep 300
sectionend

function customleave
ReadINIStr $user_def "$PLUGINSDIR\custom.ini" "field 2" "state"
strcmp "$user_def" "" 0 end
!insertmacro unselectsection ${usr1}
SectionSetText ${usr1} ""
end:
functionend

function customcreate
InstallOptions::Dialog "$PLUGINSDIR\custom.ini"
pop $0
functionend

function .onInit
InitPluginsDir
WriteIniStr "$PLUGINSDIR\custom.ini" "settings" "numfields" "2"

WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "type" "groupbox"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "left" "0"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "right" "-1"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "top" "10"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "bottom" "-11"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 1" "text" "Select User Defined Directory"

WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "type" "dirrequest"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "left" "10"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "right" "-10"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "top" "30"
WriteIniStr "$PLUGINSDIR\custom.ini" "field 2" "bottom" "44"
functionend

ok here is some code (only a small part as the full source is 300+ lines). when i use SECTION_OFF instead of SF_RO the nsis installer doesn't execute the post section but no errors given

* the ini:
[Field 4]
Type=DirRequest
Left=30
Top=111
Right=220
Bottom=124
Text=MySQL dir
Root=C:\Program Files
Flags=PATH_MUST_EXIST

* the nsi :

Section /o "Import SQL" sect14
SectionIn 3
Call ImportSql
SectionEnd

...

Function .onMouseOverSection
StrCmp $mySqlPath "" 0 +2 <- $mySqlPath read from the ini previously
SectionSetFlags ${sect14} ${SECTION_OFF}
FunctionEnd


I feel I'm a bit confused here...
StrCmp $mySqlPath should be done in custom page leave callback and according to that select/unselect the Import SQL section, even better hide it.
.onMouseOverSection callback is for setting up sections description as far I know.
The way I understand your installer is more/less like the sample I've posted above, and has no bugs.


Red Wine thank you for the explaination !
My problem was I never saw the command "!insertmacro unselectsection" in the documentation so i tried to create something similar to this.
It doesn't explain why the .post section is buggy with my code , but thanks to you my code is nicer!


Allow me to add a few comments further,
hard coding is not good idea, so Root=C:\Program Files might works as expected on your machine but you don't know if exists on others machines, therefore the accurate way should be Root=$PROGRAMFILES which you may write it to ini at runtime before the call to the InstallOptions plugin.
Also, Flags=PATH_MUST_EXIST affects FileRequest controls, you don't need it in a DirRequest control.


Red Wine thank you again for all your precious infos.
The program files line in my code was just to debug in my case :) As I get the path value from the registry (using the code I posted in another topic).
Anyway, your comments could be useful later.