Page 1 of 1

Slow when inspecting dozens of objects

PostPosted: Mon Oct 20, 2014 2:05 pm
by amarryat
Is there a strategy to speed up the object inspector's processing when inspecting a hundred objects for example?

I have an objects editor, where a user may want to select 100 objects on the screen and change their color for instance. Once there are more than 20 or so objects selected, the inspector lags, and the more there are, the longer it takes. It could take a few seconds if there are 100 objects selected.

This happens after code like this (SH is a control that has a bunch of objects on it), and Self is the object inspector being used via a class helper:

for i := 0 to SH.ChildCount-1 do
if SH.Children[i] is THMI then
Self.Objects.Add.Component := SH.Children[i];

The code above processes instantly, but after that the screen has to redraw, and I believe this is where the pause occurs.

Re: Slow when inspecting dozens of objects

PostPosted: Mon Oct 20, 2014 2:29 pm
by Inspex
Hi,
When you are adding lots of objects to the inspector, you need to wrap it in BeginUpdate/EndUpdate calls:
Self.Objects. BeginUpdate;
Try
for i := 0 to SH.ChildCount-1 do
if SH.Children[i] is THMI then
Self.Objects.Add.Component := SH.Children[i];
Finally
Self.Objects. EndUpdate;
Regards,
Tom

Re: Slow when inspecting dozens of objects

PostPosted: Mon Oct 20, 2014 2:36 pm
by amarryat
Inspex wrote:Hi,
When you are adding lots of objects to the inspector, you need to wrap it in BeginUpdate/EndUpdate calls:
Self.Objects. BeginUpdate;
Try
for i := 0 to SH.ChildCount-1 do
if SH.Children[i] is THMI then
Self.Objects.Add.Component := SH.Children[i];
Finally
Self.Objects. EndUpdate;
Regards,
Tom



Thank you! That did the trick. Not sure why I didn't have that in there since that's exactly what I was doing when adding filters and categories.