Skip to content

Commit f5c27c7

Browse files
committed
Half-fix of another GLC problem
1 parent 749e701 commit f5c27c7

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/editors/layout/LayoutUndoCommands.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff 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)

0 commit comments

Comments
 (0)