ソースを参照

Tab Book - Remove Tab Bug

Fixed a bug where tabs were not correctly removed.
Peter Robinson 4 年 前
コミット
f1f47ece23

+ 12 - 2
engine/source/gui/guiControl.cc

@@ -258,16 +258,26 @@ void GuiControl::addObject(SimObject *object)
   GuiControl *parent = ctrl->getParent();
   GuiControl *parent = ctrl->getParent();
   if( parent )
   if( parent )
      parent->onChildAdded( ctrl );
      parent->onChildAdded( ctrl );
-
-
 }
 }
 
 
 void GuiControl::removeObject(SimObject *object)
 void GuiControl::removeObject(SimObject *object)
 {
 {
+	GuiControl *ctrl = dynamic_cast<GuiControl *>(object);
+	if (!ctrl)
+	{
+		AssertWarn(0, "GuiControl::removeObject: attempted to remove NON GuiControl from set");
+		return;
+	}
+	GuiControl *parent = ctrl->getParent();
+
    AssertFatal(mAwake == static_cast<GuiControl*>(object)->isAwake(), "GuiControl::removeObject: child control wake state is bad");
    AssertFatal(mAwake == static_cast<GuiControl*>(object)->isAwake(), "GuiControl::removeObject: child control wake state is bad");
    if (mAwake)
    if (mAwake)
       static_cast<GuiControl*>(object)->sleep();
       static_cast<GuiControl*>(object)->sleep();
     Parent::removeObject(object);
     Parent::removeObject(object);
+
+	// If we are a child, notify our parent that we've been removed
+	if (parent)
+		parent->onChildRemoved(ctrl);
 }
 }
 
 
 GuiControl *GuiControl::getParent()
 GuiControl *GuiControl::getParent()

+ 3 - 0
engine/source/gui/guiControl.h

@@ -488,6 +488,9 @@ public:
     /// Called when this object has a new child. Congratulations!
     /// Called when this object has a new child. Congratulations!
     virtual void onChildAdded( GuiControl *child );
     virtual void onChildAdded( GuiControl *child );
 
 
+	/// Called when a child is removed.
+	virtual inline void onChildRemoved(GuiControl* child) {};
+
     /// @}
     /// @}
 
 
     /// @name Console
     /// @name Console

+ 1 - 1
engine/source/gui/guiListBoxCtrl.cc

@@ -587,7 +587,7 @@ void GuiListBoxCtrl::setItemText( S32 index, StringTableEntry text )
 #pragma region Sizing
 #pragma region Sizing
 void GuiListBoxCtrl::updateSize()
 void GuiListBoxCtrl::updateSize()
 {
 {
-   if( !mProfile )
+   if( !mProfile || !mProfile->mFont )
       return;
       return;
 
 
    GFont *font = mProfile->mFont;
    GFont *font = mProfile->mFont;