From 444add330f34ffff6d28d769cfbb00bbc5243ebe Mon Sep 17 00:00:00 2001 From: BDisp Date: Mon, 13 Feb 2023 20:21:27 +0000 Subject: [PATCH] Fixes #2346. If WindowsDriver is maximized crash on the Cleanup method. --- 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 21ea48300..d7b72fe37 100644 --- a/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/WindowsDriver.cs @@ -287,6 +287,9 @@ namespace Terminal.Gui { position = new Point (csbi.srWindow.Left, csbi.srWindow.Top); SetConsoleOutputWindow (csbi); var winRect = new SmallRect (0, 0, (short)(sz.Width - 1), (short)Math.Max (sz.Height - 1, 0)); + if (!SetConsoleScreenBufferInfoEx (OutputHandle, ref csbi)) { + throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); + } if (!SetConsoleWindowInfo (OutputHandle, true, ref winRect)) { throw new System.ComponentModel.Win32Exception (Marshal.GetLastWin32Error ()); } @@ -1463,7 +1466,7 @@ namespace Terminal.Gui { CurrentAttribute = MakeColor (Color.White, Color.Black); InitalizeColorSchemes (); - + ResizeScreen (); UpdateOffScreen (); } catch (Win32Exception e) { @@ -1571,7 +1574,7 @@ namespace Terminal.Gui { if (runeWidth < 0 || runeWidth > 0) { ccol++; } - + if (runeWidth > 1) { if (validClip && ccol < Clip.Right) { position = GetOutputBufferPosition ();