Skip to content

Commit

Permalink
Fixes #2784. CursesDriver throws System.StackOverflowException on con…
Browse files Browse the repository at this point in the history
…sole resizing.
BDisp authored and tig committed Aug 8, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 6590c58 commit 17f123b
Showing 3 changed files with 14 additions and 6 deletions.
11 changes: 8 additions & 3 deletions Terminal.Gui/ConsoleDrivers/CursesDriver/CursesDriver.cs
Original file line number Diff line number Diff line change
@@ -142,7 +142,6 @@ public override void Refresh ()
Curses.raw ();
Curses.noecho ();
Curses.refresh ();
ProcessWinChange ();
}

private void ProcessWinChange ()
@@ -338,7 +337,13 @@ void ProcessInput ()

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 @@ public override void PrepareToRun (MainLoop mainLoop, Action<KeyEvent> keyHandle
});

mLoop.WinChanged += () => {
ProcessWinChange ();
ProcessInput ();
};
}

4 changes: 2 additions & 2 deletions Terminal.Gui/ConsoleDrivers/CursesDriver/UnixMainLoop.cs
Original file line number Diff line number Diff line change
@@ -97,8 +97,8 @@ void IMainLoopDriver.Setup (MainLoop mainLoop)
{
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;
});
}
5 changes: 4 additions & 1 deletion Terminal.Gui/ConsoleDrivers/CursesDriver/binding.cs
Original file line number Diff line number Diff line change
@@ -160,7 +160,10 @@ public static bool CheckWinChange ()

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;

0 comments on commit 17f123b

Please sign in to comment.