From 3d8d85b5b9d670c678a63360839b9c386a0c5c8c Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Mon, 18 Mar 2024 10:40:07 +0100 Subject: [PATCH] Terminal: Ignore "height = 0" resize events ConPTY on windows will send "clear line" characters in response to resizing the PTY. During re-showing the terminal pane the widget receives a "height=0" resize event. We have to ignore this otherwise the conpty might try to clear the screen. Another issue was that we are calling resize on the pty even thought the process has ended and won't be able to respond to the clear attempty by the pty anymore. Fixes: QTCREATORBUG-30523 Change-Id: I24caeaffb31d255a0640952e2d35bda23fd16280 Reviewed-by: Cristian Adam --- src/libs/solutions/terminal/terminalview.cpp | 5 ++++- src/plugins/terminal/terminalwidget.cpp | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libs/solutions/terminal/terminalview.cpp b/src/libs/solutions/terminal/terminalview.cpp index 0cebe6d9b99..472346b3fcb 100644 --- a/src/libs/solutions/terminal/terminalview.cpp +++ b/src/libs/solutions/terminal/terminalview.cpp @@ -958,11 +958,14 @@ void TerminalView::applySizeChange() }; if (newLiveSize.height() <= 0) - newLiveSize.setHeight(1); + return; if (newLiveSize.width() <= 0) newLiveSize.setWidth(1); + if (d->m_surface->liveSize() == newLiveSize) + return; + resizePty(newLiveSize); d->m_surface->resize(newLiveSize); flushVTerm(true); diff --git a/src/plugins/terminal/terminalwidget.cpp b/src/plugins/terminal/terminalwidget.cpp index 2bd0fa403dd..756f1a11bee 100644 --- a/src/plugins/terminal/terminalwidget.cpp +++ b/src/plugins/terminal/terminalwidget.cpp @@ -336,7 +336,7 @@ qint64 TerminalWidget::writeToPty(const QByteArray &data) void TerminalWidget::resizePty(QSize newSize) { - if (m_process && m_process->ptyData()) + if (m_process && m_process->ptyData() && m_process->isRunning()) m_process->ptyData()->resize(newSize); }