### GuiTreeViewCtrl "insertItem" unexpected behavior

Scripting questions, discussions, etc

#### GuiTreeViewCtrl "insertItem" unexpected behavior

xetra11
Posts: 12
Joined: Mon Jul 11, 2016 8:39 pm
The code: http://hastebin.com/fivudaraje.coffee

When trying to run this script - the program crashes. When I ommit the inserting to the 9th child element it works fine. That tells me - that adding new subitem only works on the last created child to the root node. Is that expected behavior and I just missed to realise it? But how can I add a subitem to, let say, the 5th root element or the 9th like in the example?

Please give me a hint what I'm missing here!

greets Charlie!

#### Re: GuiTreeViewCtrl "insertItem" unexpected behavior

Johxz
Posts: 441
Joined: Sat Feb 07, 2015 11:37 pm
Hey hi @ xetra11

I forgot this issue or not sure maybe is not an issue Issue #1248 right now not remember the workaround I think from here GUI Editor - Tutorial Advanced you can learn how to use "insertItem".

#### Re: GuiTreeViewCtrl "insertItem" unexpected behavior

JeffR
Steering Committee
Posts: 840
Joined: Tue Feb 03, 2015 9:49 pm

Can you modify line 4013 in guiTreeViewCtrl.cpp so it looks like:
if (parent->mNext && mProfile->mBitmapArrayRects.size() - 1 >= BmpLine)
and give it another shot?

Looks like when there's a valid item listed in mNext(so we go from a subItem to the next parent's child item) it's not properly vouching that the little line icon exists in the gui profile, so we get a crash.

Lemme know if that corrected it for you.

#### Re: GuiTreeViewCtrl "insertItem" unexpected behavior

JeffR
Steering Committee
Posts: 840
Joined: Tue Feb 03, 2015 9:49 pm

Can you modify line 4013 in guiTreeViewCtrl.cpp so it looks like:
if (parent->mNext && mProfile->mBitmapArrayRects.size() - 1 >= BmpLine)
Making the whole block look like:
// Do we draw the tree lines?
if( mFlags.test(ShowTreeLines) )
{
drawRect.point.x += ( mTabSize * item->mTabLevel );
Item* parent = item->mParent;
for ( S32 i = item->mTabLevel; ( parent && i > 0 ); i-- )
{
drawRect.point.x -= mTabSize;
if (parent->mNext && mProfile->mBitmapArrayRects.size() - 1 >= BmpLine)
drawer->drawBitmapSR( mProfile->mTextureObject, drawRect.point, mProfile->mBitmapArrayRects[BmpLine] );

parent = parent->mParent;
}
}
and give it another shot?

Looks like when there's a valid item listed in mNext(so we go from a subItem to the next parent's child item) it's not properly vouching that the little line icon exists in the gui profile, so we get a crash.

Lemme know if that corrected it for you.

#### Who is online

Users browsing this forum: No registered users and 1 guest