forked from qt-creator/qt-creator
Terminal: Fix flushing after process has finished
Fixes: QTCREATORBUG-30733 Change-Id: I4b6274d15efbd1b2e6c8ea4960683a4f6bc8952e Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
15
src/libs/3rdparty/libptyqt/conptyprocess.cpp
vendored
15
src/libs/3rdparty/libptyqt/conptyprocess.cpp
vendored
@@ -988,8 +988,11 @@ bool ConPtyProcess::startProcess(const QString &executable,
|
|||||||
GetExitCodeProcess(hEvent, &exitCode);
|
GetExitCodeProcess(hEvent, &exitCode);
|
||||||
m_exitCode = exitCode;
|
m_exitCode = exitCode;
|
||||||
// Do not respawn if the object is about to be destructed
|
// Do not respawn if the object is about to be destructed
|
||||||
if (!m_aboutToDestruct)
|
if (!m_aboutToDestruct) {
|
||||||
|
ConptyClosePseudoConsole(m_ptyHandler);
|
||||||
|
m_ptyHandler = INVALID_HANDLE_VALUE;
|
||||||
emit notifier() -> aboutToClose();
|
emit notifier() -> aboutToClose();
|
||||||
|
}
|
||||||
m_shellCloseWaitNotifier->setEnabled(false);
|
m_shellCloseWaitNotifier->setEnabled(false);
|
||||||
}, Qt::QueuedConnection);
|
}, Qt::QueuedConnection);
|
||||||
|
|
||||||
@@ -1028,7 +1031,7 @@ bool ConPtyProcess::startProcess(const QString &executable,
|
|||||||
|
|
||||||
bool ConPtyProcess::resize(qint16 cols, qint16 rows)
|
bool ConPtyProcess::resize(qint16 cols, qint16 rows)
|
||||||
{
|
{
|
||||||
if (m_ptyHandler == nullptr)
|
if (m_ptyHandler == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1047,13 +1050,12 @@ bool ConPtyProcess::resize(qint16 cols, qint16 rows)
|
|||||||
|
|
||||||
bool ConPtyProcess::kill()
|
bool ConPtyProcess::kill()
|
||||||
{
|
{
|
||||||
bool exitCode = false;
|
|
||||||
|
|
||||||
if (m_ptyHandler != INVALID_HANDLE_VALUE) {
|
if (m_ptyHandler != INVALID_HANDLE_VALUE) {
|
||||||
m_aboutToDestruct = true;
|
m_aboutToDestruct = true;
|
||||||
|
|
||||||
// Close ConPTY - this will terminate client process if running
|
// Close ConPTY - this will terminate client process if running
|
||||||
WindowsContext::instance().closePseudoConsole(m_ptyHandler);
|
WindowsContext::instance().closePseudoConsole(m_ptyHandler);
|
||||||
|
}
|
||||||
|
|
||||||
// Clean-up the pipes
|
// Clean-up the pipes
|
||||||
if (INVALID_HANDLE_VALUE != m_hPipeOut)
|
if (INVALID_HANDLE_VALUE != m_hPipeOut)
|
||||||
@@ -1086,10 +1088,7 @@ bool ConPtyProcess::kill()
|
|||||||
HeapFree(GetProcessHeap(), 0, m_shellStartupInfo.lpAttributeList);
|
HeapFree(GetProcessHeap(), 0, m_shellStartupInfo.lpAttributeList);
|
||||||
}
|
}
|
||||||
|
|
||||||
exitCode = true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IPtyProcess::PtyType ConPtyProcess::type()
|
IPtyProcess::PtyType ConPtyProcess::type()
|
||||||
|
@@ -435,13 +435,22 @@ public:
|
|||||||
static_cast<Pty::PtyInputFlag>(m_inputFlags.toInt()));
|
static_cast<Pty::PtyInputFlag>(m_inputFlags.toInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
emit readyRead(m_ptyProcess->readAll(), {});
|
const QByteArray data = m_ptyProcess->readAll();
|
||||||
|
if (!data.isEmpty())
|
||||||
|
emit readyRead(data, {});
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_ptyProcess->notifier(), &QIODevice::aboutToClose, this, [this] {
|
connect(m_ptyProcess->notifier(), &QIODevice::aboutToClose, this, [this] {
|
||||||
if (m_ptyProcess) {
|
if (m_ptyProcess) {
|
||||||
const ProcessResultData result
|
const ProcessResultData result
|
||||||
= {m_ptyProcess->exitCode(), QProcess::NormalExit, QProcess::UnknownError, {}};
|
= {m_ptyProcess->exitCode(), QProcess::NormalExit, QProcess::UnknownError, {}};
|
||||||
|
|
||||||
|
const QByteArray restOfOutput = m_ptyProcess->readAll();
|
||||||
|
if (!restOfOutput.isEmpty()) {
|
||||||
|
emit readyRead(restOfOutput, {});
|
||||||
|
m_ptyProcess->notifier()->disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
emit done(result);
|
emit done(result);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user