Describe the bug
Staxrip crashes when the user clicks on the menu button in the processing form between two encodes.
System InvalidOperationException: Sequence contains no matching element.
at System.Linq.Enumerable.FirstTSource
at StaxRip.ProcessingForm.bnMenu_Click(Object sender, EventArgs e) in D:\Code\Github\staxrip\staxrip\Source\Forms\ProcessingForm.vb:Line 394.
at System.Windows.Forms.Control.OnClick(EventArgs €)
at System.Windows.Forms.Button.OnClick(EventArgs €)
at StaxRip.UI.ButtonEx.OnClick(EventArgs e) in D:\Code\Github\staxrip\staxrip\Source\UI\Controls\Controls.vb:Line 1884.
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(intPtr hWnd, Int32 msg, IntPtr wparam, IntPtr Iparam)
Expected behavior
It shouldn't crash 😄
How to reproduce the issue
Provide information
This happens because in ProcessingForm.vb:Line 392 the .First(...) call returns an emtpy sequence.
Dim priorityText = _priorities.First(Function(x) x.Key = ProcController.GetProcessPriority()).Value
the easy fix would be to just use FirstOrDefault() and add a null check:
Dim priorityText = _priorities.FirstOrDefault(Function(x) x.Key = ProcController.GetProcessPriority())
If priorityText IsNot Nothing Then
For Each item In CMS.GetItems().OfType(Of MenuItemEx).Where(Function(i) i.Path.StartsWith(_priorityMenuName + " | "))
item.Checked = item.Path.EndsWith($" | {priorityText.Value}")
Next
End If
But I didn't check what would happen if the user interacts with the priority setting while there is no active encode. Maybe the menu for process priority could be hidden in this case.
Thanks for reporting. 👍
It's already fixed and will be rolled out with the next release.
Most helpful comment
Thanks for reporting. 👍
It's already fixed and will be rolled out with the next release.