From 69e8cf4e6bd1d78a5b6763b68724633652ca8ef8 Mon Sep 17 00:00:00 2001 From: Markus Hofknecht Date: Thu, 18 Nov 2021 00:52:24 +0100 Subject: [PATCH] [BUG] Fix a rare exception when moving trough menu by keyboard and execute file (#240), version 1.0.27.3 --- Business/KeyboardInput.cs | 21 ++++++++++++++------- Config/Config.cs | 2 +- Properties/AssemblyInfo.cs | 4 ++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Business/KeyboardInput.cs b/Business/KeyboardInput.cs index 27aa048..936fe14 100644 --- a/Business/KeyboardInput.cs +++ b/Business/KeyboardInput.cs @@ -76,7 +76,7 @@ namespace SystemTrayMenu.Handler { case Keys.Enter: SelectByKey(keys); - menus[iMenuKey].FocusTextBox(); + menus[iMenuKey]?.FocusTextBox(); break; case Keys.Left: if (Properties.Settings.Default.AppearAtTheBottomLeft) @@ -106,7 +106,7 @@ namespace SystemTrayMenu.Handler SelectByKey(keys); break; case Keys.Control | Keys.F: - menus[iMenuKey].FocusTextBox(); + menus[iMenuKey]?.FocusTextBox(); break; case Keys.Tab: { @@ -123,7 +123,7 @@ namespace SystemTrayMenu.Handler indexNew = indexMax; } - menus[indexNew].FocusTextBox(); + menus[indexNew]?.FocusTextBox(); } break; @@ -142,13 +142,13 @@ namespace SystemTrayMenu.Handler indexNew = 0; } - menus[indexNew].FocusTextBox(); + menus[indexNew]?.FocusTextBox(); } break; case Keys.Apps: { - DataGridView dgv = menus[iMenuKey].GetDataGridView(); + DataGridView dgv = menus[iMenuKey]?.GetDataGridView(); if (iRowKey > -1 && dgv.Rows.Count > iRowKey) @@ -331,8 +331,15 @@ namespace SystemTrayMenu.Handler ClosePressed?.Invoke(); } - // Raise Dgv_RowPostPaint to show ProcessStarted - dgv.InvalidateRow(iRowKey); + try + { + // Raise Dgv_RowPostPaint to show ProcessStarted + dgv.InvalidateRow(iRowKey); + } + catch (ArgumentOutOfRangeException ex) + { + Log.Warn("InvalidateRow failed", ex); + } } else { diff --git a/Config/Config.cs b/Config/Config.cs index effd660..d444b3a 100644 --- a/Config/Config.cs +++ b/Config/Config.cs @@ -48,7 +48,7 @@ namespace SystemTrayMenu AppColors.BitmapFilesCount.Dispose(); } - internal static Icon GetAppIcon() + public static Icon GetAppIcon() { if (Settings.Default.UseIconFromRootFolder) { diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index af1d4d3..e5d374c 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.27.2")] -[assembly: AssemblyFileVersion("1.0.27.2")] +[assembly: AssemblyVersion("1.0.27.3")] +[assembly: AssemblyFileVersion("1.0.27.3")]