From 6e483d72800a091313cce323b51b86c61dbf7dbc Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sat, 25 Nov 2023 02:25:03 +0300 Subject: [PATCH] Handle non-alive menu items during addition/removal --- osu.Framework/Graphics/UserInterface/Menu.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Framework/Graphics/UserInterface/Menu.cs b/osu.Framework/Graphics/UserInterface/Menu.cs index 4c83ab9b86..bf93c76c1d 100644 --- a/osu.Framework/Graphics/UserInterface/Menu.cs +++ b/osu.Framework/Graphics/UserInterface/Menu.cs @@ -293,7 +293,7 @@ public void Insert(int position, MenuItem item) drawableItem.SetFlowDirection(Direction); - var items = ItemsContainer.FlowingChildren.Cast().ToList(); + var items = Children.OrderBy(ItemsContainer.GetLayoutPosition).ToList(); for (int i = position; i < items.Count; i++) ItemsContainer.SetLayoutPosition(items[i], i + 1); @@ -318,7 +318,7 @@ private void itemStateChanged(DrawableMenuItem item, MenuItemState state) /// Whether was successfully removed. public bool Remove(MenuItem item) { - var items = ItemsContainer.FlowingChildren.Cast().ToList(); + var items = Children.OrderBy(ItemsContainer.GetLayoutPosition).ToList(); bool removed = false; for (int i = 0; i < items.Count; i++)