Game Development Community

GuiTreeViewCtrl text issue

by Phil Carlisle · in Torque Game Engine Advanced · 01/12/2007 (4:31 am) · 4 replies

I had a crash the other night, when tracing it, I came to

GuiTreeViewCtrl::InsertItem (I think its that, dont have the code in front of me).

In there, it has a couple of potentially nasty bugs.

Basically, it does an allocation, then passes that allocation to .setText();

If you lookat it, basically, it gets the length of the text to insert, it allocates a buffer of that size, then it passes that newly allocated buffer into set text.

Problems:

1) Buffer is not initialised
2) Text length isnt size checked for validity
3) The .setText method actually sizes the control to the largest text size. To do this, it iterates each text item and does a call to get the pixel size for each line of text..

Anyone spot the problem?

Yesss! it passes an UNINITIALISED buffer, which then gets its size checked!

So slapped wrists for whoever wrote that code.. :)

Fixes? I'll let you figure those as an exercise. (Besides, I dont have the code in front of me).

#1
01/15/2007 (5:38 pm)
That may have been fixed in TGE 1.4.2 which was merged into TGEA MS 4.1 which was pulled, but MS4.2 will be out soon and you can see if it's fixed. Confused yet?
#2
01/16/2007 (6:07 am)
I'll look out for it :)
#3
01/16/2007 (11:38 am)
@Brian - we are actually running on MS 4.1 from before it was pulled. Will check when you get 4.2 out the door, but I'm quite confident I got all code changes merged correctly.
#4
01/16/2007 (1:56 pm)
Hi guys,

I can also verify that the bug does exist in MS 4.1.

Todd