The code below is reproduced from the 2000 toolbar. This is part of the procedure that reads toolbar positions and dock statuses from an INI file. I call this procedure during initialization. This code below iterates over all the components of the main form (OwnerComponent) and loads the settings of any found toolbars.
for I := 0 to OwnerComponent.ComponentCount-1 do begin ToolWindow := OwnerComponent.Components[I]; // <------------------------ ....
This iteration takes some time (seconds - there are more than 1,500 components in the form), and I get a range error at the specified point. I found that one or more elements are leaking from the main components of the form while this loop is running, so the loop eventually tries to access one of the ends of the array as soon as this happens (it would probably be better to code this as "downto" for-loop to prevent this).
In any case, I need to find out where the main form loses the component. Can someone give me any Delphi 2006 debugging tips on how to do this? I would not expect any components of the main form to be released at this point in my program.
UPDATE
I found that when I changed the default position of the dock in the toolbar during development, I accidentally placed it on a different toolbar, and not on a dock site that had a different toolbar. I fixed the problem by removing the toolbar from the toolbar that was docked and added to the dock instead. So the problem arose:
Dock Toolbar 1 Control 1 Control 2 Toolbar 2 Control 3 Control 4
and the fix was to arrange them this way:
Dock Toolbar 1 Control 1 Control 2 Toolbar 2 Control 3 Control 4
It still indicates an error in the TB2k code, although it can be assumed that it should be able to handle nested toolbars.
source share