Browse Source

Fixes #2784. CursesDriver throws System.StackOverflowException on console resizing.

BDisp 2 years ago
parent
commit
17f123b214

+ 8 - 3
Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs

@@ -142,7 +142,6 @@ namespace Terminal.Gui {
 			Curses.raw ();
 			Curses.noecho ();
 			Curses.refresh ();
-			ProcessWinChange ();
 		}
 
 		private void ProcessWinChange ()
@@ -338,7 +337,13 @@ namespace Terminal.Gui {
 
 			if (code == Curses.KEY_CODE_YES) {
 				if (wch == Curses.KeyResize) {
-					ProcessWinChange ();
+					while (code == Curses.KEY_CODE_YES && wch == Curses.KeyResize) {
+						ProcessWinChange ();
+						code = Curses.get_wch (out wch);
+					}
+					if (wch == 0) {
+						return;
+					}
 				}
 				if (wch == Curses.KeyMouse) {
 					int wch2 = wch;
@@ -529,7 +534,7 @@ namespace Terminal.Gui {
 			});
 
 			mLoop.WinChanged += () => {
-				ProcessWinChange ();
+				ProcessInput ();
 			};
 		}
 

+ 2 - 2
Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs

@@ -97,8 +97,8 @@ namespace Terminal.Gui {
 		{
 			this.mainLoop = mainLoop;
 			pipe (wakeupPipes);
-			AddWatch (wakeupPipes [0], Condition.PollIn, ml => {
-				read (wakeupPipes [0], ignore, readHandle);
+			AddWatch (wakeupPipes [1], Condition.PollIn, ml => {
+				read (wakeupPipes [1], ignore, readHandle);
 				return true;
 			});
 		}

+ 4 - 1
Terminal.Gui/ConsoleDrivers/CursesDriver/binding.cs

@@ -160,7 +160,10 @@ namespace Unix.Terminal {
 
 			console_sharp_get_dims (out l, out c);
 
-			if (l == 1 || l != lines || c != cols) {
+			if (l < 1) {
+				l = 1;
+			}
+			if (l != lines || c != cols) {
 				lines = l;
 				cols = c;
 				return true;