# HG changeset patch # User Chris Cannam # Date 1306240167 -3600 # Node ID 5cc0d897eb2641898bea41e9ad7ea9ec88d2faca # Parent 2925975bdc9ec39ab6842b49fefb7e7d01bcceb6 Avoid crash when one of the data output callbacks is called after m_proc has already been reset (fixing #132) diff -r 2925975bdc9e -r 5cc0d897eb26 src/hgrunner.cpp --- a/src/hgrunner.cpp Thu May 19 09:45:54 2011 +0100 +++ b/src/hgrunner.cpp Tue May 24 13:29:27 2011 +0100 @@ -279,6 +279,7 @@ void HgRunner::dataReadyStdout() { DEBUG << "dataReadyStdout" << endl; + if (!m_proc) return; QString chunk = QString::fromUtf8(m_proc->readAllStandardOutput()); if (!checkPrompts(chunk)) { m_stdout += chunk; @@ -288,6 +289,7 @@ void HgRunner::dataReadyStderr() { DEBUG << "dataReadyStderr" << endl; + if (!m_proc) return; QString chunk = QString::fromUtf8(m_proc->readAllStandardError()); DEBUG << chunk; if (!checkPrompts(chunk)) { @@ -312,7 +314,9 @@ void HgRunner::finished(int procExitCode, QProcess::ExitStatus procExitStatus) { - // Save the current action and reset m_currentAction before we + if (!m_proc) return; + + // Save the current action and reset m_currentAction before we // emit a signal to mark the completion; otherwise we may be // resetting the action after a slot has already tried to set it // to something else to start a new action @@ -356,7 +360,7 @@ { if (m_isRunning) { m_currentAction.action = ACT_NONE; // so that we don't bother to notify - m_proc->kill(); + if (m_proc) m_proc->kill(); } } @@ -483,7 +487,7 @@ { DEBUG << "closeProcInput" << endl; - m_proc->closeWriteChannel(); + if (m_proc) m_proc->closeWriteChannel(); } void HgRunner::openTerminal()