Hangs during nsDialogs timer execution
I've run into a problem while making a custom page (using nsDialogs). The page mimics InstFiles except that it is used to display progress of copying files from one directory to another using list of files embed into installer. Copying files is done in loop. Page is displayed prior to InstFiles.
The problem is that after a few seconds the page is displayed the window hangs up in "not responding" mode, although copying goes on fine and if I'd wait till the end it would resume back.
I've tested without copying any files and using dummy "Sleep" commands but it made no difference. Apparently if the process in CreateTimer takes more than a few seconds the installer window becomes unresponsive.
Is there any way of preventing it from doing so?
NSIS 2.46, Windows 7 x64
Here is code for the page:
!define /math PBM_SETRANGE32 ${WM_USER} + 6
!define FILES_COUNT 2400
Page custom CopyFilesPage
Var CopyFilesPage.Dialog
Var CopyFilesPage.Status
Var CopyFilesPage.ProgressBar
Function CopyFilesPage
nsDialogs::Create 1018
Pop $CopyFilesPage.Dialog
!insertmacro MUI_HEADER_TEXT "Copy files" "Description"
${NSD_CreateLabel} 0 0 450 15 ""
Pop $CopyFilesPage.Status
${NSD_CreateProgressBar} 0 16 450 17 ""
Pop $CopyFilesPage.ProgressBar
${NSD_CreateTimer} CopyFiles 10
nsDialogs::Show
FunctionEnd
And here is the actual file copy function:
Function CopyFiles
${NSD_KillTimer} CopyFiles
InitPluginsDir
File /oname=$PLUGINSDIR\files.md5 "texts\files.md5"
FileOpen $R0 $PLUGINSDIR\files.md5 r
IfErrors 0 start
MessageBox MB_OK|MB_ICONSTOP $(INSTALL_FOLDER_NOACCESS)
Abort
start:
ClearErrors
StrCpy $9 0 ; Checking toggle
StrCpy $8 1 ; File counter
SendMessage $CopyFilesPage.ProgressBar ${PBM_SETRANGE32} 0 "${FILES_COUNT}"
loop: ; Read next file from the list and check if it exists
FileRead $R0 $1
IfErrors done
IntOp $8 $8 + 1
StrCpy $2 $1 32
StrCpy $3 $1 "" 34
${StrFilter} $3 "" "" "$\n$\r" $3
FileWrite $R1 "*$3$\r$\n"
IfFileExists "$FL_INSTDIR\$3" check
MessageBox MB_OK|MB_ICONSTOP $(COPY_FILE_MISSING)
FileWrite $R1 "File missing!$\r$\n"
Goto stop
check: ; Get file MD5 signature and compare it to the value from the list
StrCmp $9 1 copy ; Checking disabled, copy file
StrCmp $2 "--------------------------------" copy ; Don't need to verify file, copy it
md5dll::GetMD5File "$SOURCEDIR\$3"
Pop $4
StrCmp $2 $4 copy ; MD5 matched, copy it
MessageBox MB_YESNO|MB_ICONEXCLAMATION $(COPY_FILE_CHECK_FAIL) IDYES disableCheck IDNO
Goto stop
copy: ; Copy the file to new installation directory
CopyFiles /SILENT $SOURCEDIR\$3 $INSTDIR\$3
${NSD_SetText} $CopyFilesPage.Status "$3"
SendMessage $CopyFilesPage.ProgressBar ${PBM_SETPOS} "$8" 0
Goto loop
disableCheck: ; Disable checking
StrCpy $9 1
Goto loop
stop: ; Abort installation
FileClose $R0
Abort
done:
FileClose $R0
FunctionEnd
I suspect that I need tell NSIS to postpone some sort of window timeout so that window wouldn't hang in "not responsive" mode, but how do I do that and were in code?