From a5e355c5e2074e1b76f2f7f59702ccdb2206c74f Mon Sep 17 00:00:00 2001 From: Wouter Tinus Date: Mon, 16 May 2022 22:57:53 +0200 Subject: [PATCH] fix nullref on unclean shutdown (#1725) --- Terminal.Gui/ConsoleDrivers/WindowsDriver.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs index c0ea00e8a..02dd213de 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -1892,8 +1892,11 @@ namespace Terminal.Gui { void IMainLoopDriver.MainIteration () { while (resultQueue.Count > 0) { - var inputEvent = resultQueue.Dequeue () [0]; - ProcessInput?.Invoke (inputEvent); + var inputRecords = resultQueue.Dequeue (); + if (inputRecords != null && inputRecords.Length > 0) { + var inputEvent = inputRecords [0]; + ProcessInput?.Invoke (inputEvent); + } } if (winChanged) { winChanged = false;