Forráskód Böngészése

Fixed Adding/Removing GuiCtrl Problems

Fixed some problems with adding and removing GuiControls.
Peter Robinson 3 éve
szülő
commit
f3b4195f25

+ 5 - 0
engine/source/gui/containers/guiWindowCtrl.cc

@@ -865,6 +865,11 @@ void GuiWindowCtrl::getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEve
 {
 	Point2I mousePos  = lastGuiEvent.mousePoint;
 	RectI winRect   = mBounds;
+	GuiControl* parent = getParent();
+	if (!parent)
+	{
+		return;
+	}
 	Point2I offset = getParent()->localToGlobalCoord(Point2I(0,0));
 	RectI rightRect = RectI( ( ( winRect.extent.x + winRect.point.x ) - mResizeRightWidth + offset.x), winRect.point.y + mTitleHeight + offset.y, mResizeRightWidth, winRect.extent.y );
 	RectI bottomRect = RectI( winRect.point.x + offset.x, ( ( winRect.point.y + winRect.extent.y ) - mResizeBottomHeight) + offset.y, winRect.extent.x , mResizeBottomHeight );

+ 4 - 9
engine/source/gui/guiControl.cc

@@ -305,10 +305,7 @@ void GuiControl::addObject(SimObject *object)
    if(mAwake)
       ctrl->awaken();
 
-  // If we are a child, notify our parent that we've been added
-  GuiControl *parent = ctrl->getParent();
-  if( parent )
-     parent->onChildAdded( ctrl );
+    onChildAdded( ctrl );
 }
 
 void GuiControl::removeObject(SimObject *object)
@@ -319,16 +316,14 @@ void GuiControl::removeObject(SimObject *object)
 		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 == ctrl->isAwake(), "GuiControl::removeObject: child control wake state is bad");
    if (mAwake)
-      static_cast<GuiControl*>(object)->sleep();
+      ctrl->sleep();
     Parent::removeObject(object);
 
 	// If we are a child, notify our parent that we've been removed
-	if (parent)
-		parent->onChildRemoved(ctrl);
+	onChildRemoved(ctrl);
 }
 
 GuiControl *GuiControl::getParent()