Board index » delphi » Wierd stack overflow in TListView/trying to speed up TListView

Wierd stack overflow in TListView/trying to speed up TListView

I've run across some very bizzaire behaviour.  I have the potential for
a whole slew of data items to list. Adding them with OwnerData = False
is ssssllllloooowwwww; it takes about 60 seconds just to load the list
view inside the BeginUpdate..EndUpdate.

Thus I've been trying to implement the "virtual" flavour of the
TListView.

I have a list box with OwnerData = True.

After building an in-memory cache of information to display in the
cache, I do the following:

   lvFiles.Items.BeginUpdate;
   lvFiles.Items.Count := FCache.Count;
   lvFiles.Items.EndUpdate;

I have an OnData event handler that does the following:

   if Item.Index >= FCache.Count then exit; // paranoid check
   s := ChangeFileExt( FCache.Items[Item.Index].Name, '' );
   Item.Caption := s;
   ...
   etc.

This seems to work fine the first time through. When the cached data is
changed and I attempt to call BeginUpdate, it immediately calls the
OnData event handler. When the OnData handler attempts to assign the
string "s" to Item.Caption, then I get a stack overflow error. When I do
a step into, "Item.Caption := s" recursively calls OnData, which I think
is the cause of the stack overflow; I don't have the patience to keep
stepping recursively until it does. :-)

What gives? I don't understand why BeginUpdate is triggering the OnData
event handler. I assume that the caption change triggers and update
which calls the event handler which changes the caption which... you get
the idea.

I've poured over the Delphi4\Demos\Virtual ListView\VListView.dfm
example that comes with D4, but AFAIK I'm not doing anything funny. In
fact, what I'm doing is a simplified version. I do not have event
handlers for either OnDataFind or OnDataHint -- from what I understand
in the help files they are not critical.

Thanks so much!

James

--
It's coming... http://www.countdown9199.com

 

Re:Wierd stack overflow in TListView/trying to speed up TListView


Quote
James Knowles wrote:

> I've run across some very bizzaire behaviour.  

I've narrowed it down to the use of several columns with a width of -1.
Is there some way to enable this, or do I need to calculate it myself on
the fly?

Thanks,

James

--
It's coming... http://www.countdown9199.com

Other Threads