forked from qt-creator/qt-creator
Process: Refactor timeout handling
Rename ProcessResult::Hang into Canceled. Change the behavior of the Process: Whenever the terminate() or kill() is called, including indirect calls through stop() or runBlocking()'s timeout, mark the process result as Canceled. In this way the Process running by a call to start() may also finish with Canceled state. Before it was only happening for processes started via runBlocking(). Adapt the runBlockingStdOut_data() test accordingly. Get rid of ProcessInterface::m_canceledByUser field. Use ProcessResult::Canceled state instead. Fix existing 3 usages of m_canceledByUser field. Use standarized exitMessage() method for them. Add automatic measurement of process execution. Introduce processDuration() getter. Use it for reporting exitMessage() instead of timeoutS(). Change-Id: I1a68559ce844caef863a97a6b0577b0238011f70 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -225,8 +225,6 @@ private:
|
||||
void processDone();
|
||||
void timeout();
|
||||
|
||||
void errorTermination(const QString &msg);
|
||||
|
||||
Process m_process;
|
||||
QTimer m_timer;
|
||||
FilePath m_binary;
|
||||
@@ -293,12 +291,6 @@ void QueryContext::start()
|
||||
m_process.start();
|
||||
}
|
||||
|
||||
void QueryContext::errorTermination(const QString &msg)
|
||||
{
|
||||
if (!m_process.resultData().m_canceledByUser)
|
||||
VcsOutputWindow::appendError(msg);
|
||||
}
|
||||
|
||||
void QueryContext::terminate()
|
||||
{
|
||||
m_process.stop();
|
||||
@@ -313,14 +305,10 @@ void QueryContext::processDone()
|
||||
if (!m_error.isEmpty())
|
||||
emit errorText(m_error);
|
||||
|
||||
if (m_process.exitStatus() == QProcess::CrashExit)
|
||||
errorTermination(Git::Tr::tr("%1 crashed.").arg(m_binary.toUserOutput()));
|
||||
else if (m_process.exitCode())
|
||||
errorTermination(Git::Tr::tr("%1 returned %2.").arg(m_binary.toUserOutput()).arg(m_process.exitCode()));
|
||||
else if (m_process.result() != ProcessResult::FinishedWithSuccess)
|
||||
errorTermination(Git::Tr::tr("Error running %1: %2").arg(m_binary.toUserOutput(), m_process.errorString()));
|
||||
else
|
||||
if (m_process.result() == ProcessResult::FinishedWithSuccess)
|
||||
emit resultRetrieved(m_output);
|
||||
else if (m_process.result() != ProcessResult::Canceled)
|
||||
VcsOutputWindow::appendError(m_process.exitMessage());
|
||||
|
||||
emit finished();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ void FetchContext::processDone()
|
||||
deleteLater();
|
||||
|
||||
if (m_process.result() != ProcessResult::FinishedWithSuccess) {
|
||||
if (!m_process.resultData().m_canceledByUser)
|
||||
if (m_process.result() != ProcessResult::Canceled)
|
||||
VcsBase::VcsOutputWindow::appendError(m_process.exitMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user