AHK 1.1.22.09 32-bit Unicode (reluctant to go to 1.1.23.05 because of
this issue)
W7 Pro 64-bit
LV_Colors 1.1.03.00/2015-04-11
Hi just me,
As you know from my previous posts, I'm using a single-column
LV_Colors to implement what I call the Processing Console, which gives the user feedback as the program is processing. I've been troubleshooting a problem where the program hangs, and I've been able to isolate the problem as being related to
LV_Modify when using
LV_Colors. The whole script is fairly large (more than 1,500 lines) but I created a small script that reproduces the problem:
Code: Select all
; start of lines to change
#Include c:\library location\Class_LV_Colors.ahk
LogfilePath:="c:\temp"
Iterations:=10000
; end of lines to change
#Warn,UseUnsetLocal
#NoEnv
SetBatchLines,-1
FormatTime,DateTime,A_Now,yyyy-MM-dd_HH.mm.ss
Logfile:=LogfilePath . "\DebugColorsLogfile_" . DateTime . ".txt"
ColorBackground:="0xFFFFFF"
ColorText:="0xFF0000"
Gui,Color,%ColorBackground%
Gui,Font,bold s10 c0000FF,Arial
Gui,+Resize
Gui,Add,ListView,vConsoleListView hwndConsoleHandle r20 w700,Processing Console
ColorConsole:=New LV_Colors(ConsoleHandle)
GuiControl,Font,ConsoleListView
Menu,FileMenu,Add,&Run,FileMenuRun
Menu,FileMenu,Add,E&xit,FileMenuExit
Menu,MenuBar,Add,&File,:FileMenu
Gui,Menu,MenuBar
Gui,Show,w800 h500,Debug LV_Colors
Return
FileMenuRun:
Loop,%Iterations%
{
ConsoleRow:="Loop index=" . A_Index " at " . A_Now
FileAppend,%ConsoleRow%`n,%Logfile%
If (ErrorLevel<>0)
Goto,FileAppendError
RowNumber:=LV_Add("",ConsoleRow)
ConsoleRow:="Return from LV_Add at " . A_Now . " with row number " . RowNumber
FileAppend,%ConsoleRow%`n,%Logfile%
If (ErrorLevel<>0)
Goto,FileAppendError
LV_Modify(RowNumber,"Vis") ; scroll LV so newly added last row is visible - seems to be the culprit!
ConsoleRow:="Return from LV_Modify at " . A_Now . " with row number " . RowNumber
FileAppend,%ConsoleRow%`n,%Logfile%
If (ErrorLevel<>0)
Goto,FileAppendError
ColorConsole.Row(RowNumber,ColorBackground,ColorText)
ConsoleRow:="Return from ColorConsole at " . A_Now . " with row number " . RowNumber . " CB=" . ColorBackground . " CT=" . ColorText
FileAppend,%ConsoleRow%`n,%Logfile%
If (ErrorLevel<>0)
Goto,FileAppendError
GuiControl,+Redraw,%ConsoleHandle%
ConsoleRow:="Return from GuiControl Redraw at " . A_Now . " with Console Handle " . ConsoleHandle
FileAppend,%ConsoleRow%`n,%Logfile%
If (ErrorLevel<>0)
Goto,FileAppendError
}
Return
FileAppendError:
MsgBox,4112,Fatal Error,Error Level %ErrorLevel% from FileAppend
ExitApp
FileMenuExit:
GuiClose:
GuiEscape:
ExitApp
When you do a File>Run on the above, it will eventually hang. The logfile shows that it returns from the
LV_Add and then dies, meaning that it never comes back from the following
LV_Modify (unless it's hanging in
FileAppend to write the logfile, which I think is highly unlikely). It dies at different places — I ran it ten times and it hung at these rows (random, as far as I can tell):
652
53
56
202
93
2287
483
128
183
1111
I then commented out the
LV_Colors code:
Code: Select all
; start of lines to change
#Include c:\library location\Class_LV_Colors.ahk
LogfilePath:="c:\temp"
Iterations:=10000
; end of lines to change
#Warn,UseUnsetLocal
#NoEnv
SetBatchLines,-1
FormatTime,DateTime,A_Now,yyyy-MM-dd_HH.mm.ss
Logfile:=LogfilePath . "\DebugColorsLogfile_" . DateTime . ".txt"
ColorBackground:="0xFFFFFF"
ColorText:="0xFF0000"
Gui,Color,%ColorBackground%
Gui,Font,bold s10 c0000FF,Arial
Gui,+Resize
Gui,Add,ListView,vConsoleListView hwndConsoleHandle r20 w700,Processing Console
;ColorConsole:=New LV_Colors(ConsoleHandle)
GuiControl,Font,ConsoleListView
Menu,FileMenu,Add,&Run,FileMenuRun
Menu,FileMenu,Add,E&xit,FileMenuExit
Menu,MenuBar,Add,&File,:FileMenu
Gui,Menu,MenuBar
Gui,Show,w800 h500,Debug LV_Colors
Return
FileMenuRun:
Loop,%Iterations%
{
ConsoleRow:="Loop index=" . A_Index " at " . A_Now
FileAppend,%ConsoleRow%`n,%Logfile%
If (ErrorLevel<>0)
Goto,FileAppendError
RowNumber:=LV_Add("",ConsoleRow)
ConsoleRow:="Return from LV_Add at " . A_Now . " with row number " . RowNumber
FileAppend,%ConsoleRow%`n,%Logfile%
If (ErrorLevel<>0)
Goto,FileAppendError
LV_Modify(RowNumber,"Vis") ; scroll LV so newly added last row is visible - seems to be the culprit!
ConsoleRow:="Return from LV_Modify at " . A_Now . " with row number " . RowNumber
FileAppend,%ConsoleRow%`n,%Logfile%
If (ErrorLevel<>0)
Goto,FileAppendError
; ColorConsole.Row(RowNumber,ColorBackground,ColorText)
; ConsoleRow:="Return from ColorConsole at " . A_Now . " with row number " . RowNumber . " CB=" . ColorBackground . " CT=" . ColorText
; FileAppend,%ConsoleRow%`n,%Logfile%
; If (ErrorLevel<>0)
; Goto,FileAppendError
GuiControl,+Redraw,%ConsoleHandle%
ConsoleRow:="Return from GuiControl Redraw at " . A_Now . " with Console Handle " . ConsoleHandle
FileAppend,%ConsoleRow%`n,%Logfile%
If (ErrorLevel<>0)
Goto,FileAppendError
}
Return
FileAppendError:
MsgBox,4112,Fatal Error,Error Level %ErrorLevel% from FileAppend
ExitApp
FileMenuExit:
GuiClose:
GuiEscape:
ExitApp
The two scripts are identical except for the six commented out lines relating to the use of
LV_Colors. It processed all 10,000 iterations without hanging — four times!
Maybe I'm calling
LV_Colors incorrectly, but I'm hoping you can help me figure this out as my users find the colors in the Processing Console to be extremely helpful. But for now I've stopped using colors, as the program's hanging is a show-stopper. Thanks very much, Joe