From a9259b20a47bd43c7b35dc7abb9faf65e5ee1d69 Mon Sep 17 00:00:00 2001 From: nothingTVatYT <34131388+nothingTVatYT@users.noreply.github.com> Date: Wed, 7 Feb 2024 02:01:39 +0100 Subject: [PATCH] fix off-by-one in collection range check The check failed randomly after script reloading an dissued the following error: ``` 00:19:37.789 ]: [Error] Exception has been thrown during Window.OnDraw. Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') [ 00:19:37.805 ]: [Warning] Exception has been thrown during Window.OnUpdate. Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index') Stack strace: at FlaxEditor.GUI.Tabs.Tabs.get_SelectedTab() in /home/me/Flax/FlaxEngine/Source/Editor/GUI/Tabs/Tabs.cs:line 242 ``` --- Source/Editor/GUI/Tabs/Tabs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/GUI/Tabs/Tabs.cs b/Source/Editor/GUI/Tabs/Tabs.cs index 3c70363e7..c9b1e1eff 100644 --- a/Source/Editor/GUI/Tabs/Tabs.cs +++ b/Source/Editor/GUI/Tabs/Tabs.cs @@ -239,7 +239,7 @@ namespace FlaxEditor.GUI.Tabs /// public Tab SelectedTab { - get => _selectedIndex < 0 || Children.Count <= _selectedIndex ? null : Children[_selectedIndex + 1] as Tab; + get => _selectedIndex < 0 || Children.Count <= (_selectedIndex+1) ? null : Children[_selectedIndex + 1] as Tab; set => SelectedTabIndex = value != null ? Children.IndexOf(value) - 1 : -1; }