diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2017-03-02 16:04:36 +0100 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2017-03-02 17:34:54 +0000 |
commit | 398db8f37197f74311a859cd1ebaafb3d113370c (patch) | |
tree | 0f36dec2f43124010bedf1cf6fb5dabe26b78203 /src/lib/corelib/tools/qbsprocess.cpp | |
parent | d0bc04ede09002d6bda1798ec2f452caa99712b7 (diff) |
Fix QbsProcess::cancel()
Do proper state checking. In particular, only send a stop packet to the
launcher if we are in the running state.
This fixes a potential null pointer access when doing dry run builds.
Change-Id: Ib3efdd09c4094190c746464718d642b353ae7566
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib/corelib/tools/qbsprocess.cpp')
-rw-r--r-- | src/lib/corelib/tools/qbsprocess.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/corelib/tools/qbsprocess.cpp b/src/lib/corelib/tools/qbsprocess.cpp index 8495d72a0..52ce3f25a 100644 --- a/src/lib/corelib/tools/qbsprocess.cpp +++ b/src/lib/corelib/tools/qbsprocess.cpp @@ -88,7 +88,19 @@ void QbsProcess::doStart() void QbsProcess::cancel() { - sendPacket(StopProcessPacket(token())); + switch (m_state) { + case QProcess::NotRunning: + break; + case QProcess::Starting: + m_errorString = Tr::tr("Process canceled before it was started."); + m_error = QProcess::FailedToStart; + m_state = QProcess::NotRunning; + emit error(m_error); + break; + case QProcess::Running: + sendPacket(StopProcessPacket(token())); + break; + } } QByteArray QbsProcess::readAllStandardOutput() |