Another TextBox crash

rluck

04-09-2007 03:22:01

this->mainMenu->getSheet()->getWindow("ControlOptionsWindow")->getTextBox("MoveUnits")->setText("");

I can setText fine when the textbox is created, afterwards though it crashes the program.

kungfoomasta

04-09-2007 06:00:02

That's not really enough information for me to work with.. :lol:


void TextBox::setText(const Ogre::UTFString& text)
{
if(text == mCaption)
return;

mCaption = text;

if(mCaption == "")
return;

mVisibleStart = 0;
mVisibleEnd = 0;

// This function determines the visibleStart and visibleEnd, and
// updates the text before setting the cursor position.
setCursorIndex(static_cast<int>(mCaption.length()));
mTextCursor->setVisible(false);
}


Actually, I can see that I'm not clearing the Text object, which does the rendering. I'll add this in, it could be related to the crash you're seeing.

[edit]

Here is the current version of the code, see if you are still getting a crash. If so, please step through and give me the last QuickGUI line of execution, and the function it came from.


void TextBox::setText(const Ogre::UTFString& text)
{
if(text == mCaption)
return;

mCaption = text;

mVisibleStart = 0;
mVisibleEnd = 0;
mSelectStart = 0;
mSelectEnd = 0;

if(mCaption == "")
{
mText->setCaption("");
return;
}

// This function determines the visibleStart and visibleEnd, and
// updates the text before setting the cursor position.
setCursorIndex(static_cast<int>(mCaption.length()));
mTextCursor->setVisible(false);
}


[/edit]