Game Development Community

dev|Pro Game Development Curriculum

TGE 1.3 bugfix to Canvas.SetContent

by Orion Elenzil · 09/09/2008 (6:16 am) · 0 comments

this fix is only needed in TGE 1.3 codebases; it seems already fixed in 1.4+

this script command
Canvas.setContent(new guiControl());
crashes because GuiControl::isTabable() assumes mProfile is not NULL.

the fix:
in guiCanvas.cc,
re-arrange this code:
// lose the first responder from the old GUI
   GuiControl *oldResponder = mFirstResponder;
   mFirstResponder = gui->findFirstTabable();
   if(oldResponder && oldResponder != mFirstResponder)
      oldResponder->onLoseFirstResponder();

   //add the gui to the front
   if(!size() || gui != (*this)[0])
   {
      // automatically wakes objects in GuiControl::onWake
      addObject(gui);
      if (size() >= 2)
         reOrder(gui, *begin());
   }
to look like this: (adding the control calls onWake(), which provides the default profile if it's NULL)
//add the gui to the front
   if(!size() || gui != (*this)[0])
   {
      // automatically wakes objects in GuiControl::onWake
      addObject(gui);
      if (size() >= 2)
         reOrder(gui, *begin());
   }
   
   // lose the first responder from the old GUI
   GuiControl *oldResponder = mFirstResponder;
   mFirstResponder = gui->findFirstTabable();
   if(oldResponder && oldResponder != mFirstResponder)
      oldResponder->onLoseFirstResponder();


that's all.