You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When Alt key is pressed and MenuBarItem gets focus, attempting to move focus with left/right arrow keys causes a crash when the target MenuBarItem has an action but Menu property is set to null or an empty array.
This is caused by the framework attempting to open the menu even if it does not exist.
To Reproduce
Steps to reproduce the behavior:
Create an application with a MenuBar and at least two MenuBarItems with actions but no MenuItems assigned.
Press Alt key or focus the MenuBar by some other means.
Press right arrow key
Application crashes:
Unhandled exception. System.IndexOutOfRangeException: Index was outside the bounds of the array.
at Terminal.Gui.MenuBar.OnMenuOpened()
at Terminal.Gui.MenuBar.set_openCurrentMenu(Menu value)
at Terminal.Gui.MenuBar.OpenMenu(Int32 index, Int32 sIndex, MenuBarItem subMenu)
at Terminal.Gui.MenuBar.MoveRight()
at Terminal.Gui.MenuBar.<.ctor>b__21_1()
at Terminal.Gui.View.InvokeKeybindings(KeyEvent keyEvent)
at Terminal.Gui.MenuBar.ProcessKey(KeyEvent kb)
at Terminal.Gui.View.ProcessHotKey(KeyEvent keyEvent)
at Terminal.Gui.Application.ProcessKeyEvent(KeyEvent ke)
at Terminal.Gui.WindowsDriver.ProcessInput(InputRecord inputEvent)
at Terminal.Gui.WindowsDriver.<PrepareToRun>b__34_0(InputRecord e)
at Terminal.Gui.WindowsMainLoop.Terminal.Gui.IMainLoopDriver.MainIteration()
at Terminal.Gui.MainLoop.MainIteration()
at Terminal.Gui.Application.RunMainLoopIteration(RunState& state, Boolean wait, Boolean& firstIteration)
at Terminal.Gui.Application.RunLoop(RunState state, Boolean wait)
at Terminal.Gui.Application.Run(Toplevel view, Func`2 errorHandler)
at Terminal.Gui.Application.Run(Func`2 errorHandler)
at Program.<Main>$(String[] args) in REDACTED 105
Minimal repro code
using Terminal.Gui;
Application.Init();
var menu = new MenuBar(
menus: new[]
{
new MenuBarItem { Title = "Test 1", Action = () => { } },
new MenuBarItem { Title = "Test 2", Action = () => { } },
});
Application.Top.Add(menu);
Application.Run();
Application.Shutdown();
Expected behavior
Focus is moved without a crash.
The text was updated successfully, but these errors were encountered:
BDisp
added a commit
to BDisp/Terminal.Gui
that referenced
this issue
Nov 17, 2022
Describe the bug
When Alt key is pressed and MenuBarItem gets focus, attempting to move focus with left/right arrow keys causes a crash when the target MenuBarItem has an action but
Menu
property is set to null or an empty array.This is caused by the framework attempting to open the menu even if it does not exist.
To Reproduce
Steps to reproduce the behavior:
Minimal repro code
Expected behavior
Focus is moved without a crash.
The text was updated successfully, but these errors were encountered: