Game Development Community

TextBox (guiTextCtrl) overflow

by AlexanderSLG · in Torque Game Engine · 07/17/2007 (6:52 am) · 0 replies

GuiTextCtrl has a limit of 1024 chars, and this has problems with some of the variables that might have more than that length.

In particular when we have a list of empty squares that goes over 1024 characters and click on the Terrain Block in the World Inspector it tries to update the variables, and cuts them where the text fits, and it updates the variable in the server side so it's like the one on the textbox.

This is not only annoying but useless because really who edits (or understands for that matter) manually the list of empty squares?

We thought of making the array bigger but this means a big memory loss and changing GuiTextCtrl.mText so it's a pointer with 1024 chars allocated in the constructor and released in the destructor, and that for some reason dies at startup in this last line:
static void treeRemove(FreeHeader *hdr)
{
#ifdef TORQUE_DEBUG_GUARD
   checkGuard((Header *) hdr, false);
   setGuard((Header *) hdr, true);
#endif
   //validateTree();
   //gRemoveCount++;

   FreeHeader *prev = hdr->prevQueue;
   FreeHeader *next = hdr->nextQueue;

   if(prev)
      prev->nextQueue = next;
of platformMemory.cc with a "trying to access wrong memory address 0xc0c0c0c0" or something like that. Likewise doing this:
protected:
   StringTableEntry mInitialText;
   StringTableEntry mInitialTextID;
   Vector<UTF8> myText;
   UTF8 *mText;
in guiTextCtrl.h and this in the constructor
GuiTextCtrl::GuiTextCtrl()
{
	/******* original*********
   //default fonts
   mInitialText = StringTable->insert("");
   mInitialTextID = StringTable->insert("");
   mText[0] = '[[62812f1e09909]]';
   mMaxStrLen = GuiTextCtrl::MAX_STRING_LENGTH;
	/*****************/
   //default fonts
   //	TNOTE: changed so it's variable
   mMaxStrLen = GuiTextCtrl::MAX_STRING_LENGTH;

   myText.reserve(GuiTextCtrl::MAX_STRING_LENGTH);
   mText = myText.begin();
   mText[0] = '[[62812f1e09909]]';
dies the same way.

Is there or can anyone think of a workaround for this? why does copying to a textbox modify the original variable?

thanks in advance