File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -728,8 +728,9 @@ void LayoutMoveInHierarchyCommand::undo()
728728 if (parentLC)
729729 {
730730 const size_t currIndex = widgetManipulator->getWidgetIndexInParent ();
731- const size_t destIndex = rec.oldChildIndex ;
732- parentLC->moveChildToIndex (currIndex, destIndex > currIndex ? destIndex + 1 : destIndex);
731+ const size_t destIndex = rec.oldChildIndex > currIndex ? rec.oldChildIndex + 1 : rec.oldChildIndex ;
732+ if (destIndex < parentLC->getChildCount ())
733+ parentLC->moveChildToIndex (currIndex, destIndex);
733734 }
734735
735736 // Update widget and its previous parent (the second is mostly for the layout container case)
@@ -780,10 +781,13 @@ void LayoutMoveInHierarchyCommand::redo()
780781 widgetManipulator->setParentItem (newParentManipulator);
781782 }
782783
784+ // FIXME: there is a known bug with moving existing widgets to the GridLayoutContainer,
785+ // then undo, then redo again. It will be fixed through writing a brand new GLC.
786+
783787 // FIXME: allow reordering in any window? Needs CEGUI change.
784788 // http://cegui.org.uk/forum/viewtopic.php?f=3&t=7542
785789 auto parentLC = dynamic_cast <CEGUI ::LayoutContainer*>(newParentManipulator->getWidget ());
786- if (parentLC)
790+ if (parentLC && rec. newChildIndex < parentLC-> getChildCount () )
787791 parentLC->moveChildToIndex (widgetManipulator->getWidget (), rec.newChildIndex );
788792
789793 // Update widget and its previous parent (the second is mostly for the layout container case)
You can’t perform that action at this time.
0 commit comments