Unexpected behavior with TGListTree::SortChildren()

Hi,

I am trying to determine how to add items to a TGListTree and allow sorting at the same time. When I call the method AddItem(…), the TGListTree does not show all the items if a previous call to SortChildren() has modified the order. I’ve attached a simple code to illustrate. Do the following:

.x listTree.C

Now click the Add button four times and then the sort button once. This will give a list that looks like:
Top
—10
—7
—8
—9

Now click the Add button again. This will produce:
Top
—10
—7
—6

whereas I expected it to produce:
Top
—10
—7
—8
—9
—6

(assuming that AddItem() places the new item at the end of the list). Is this the expected behavior? If so, is there a way to add a new item to the end of a sorted list?

Thanks,

Glen
listTree.C (1.9 KB)

Hi Glen,

This is obviously a bug :blush: It is fixed now in svn trunk. Thanks a lot for the report!

Cheers,
Bertrand.

Thanks for the quick fix!