changeset 385:5cc0d897eb26

Avoid crash when one of the data output callbacks is called after m_proc has already been reset (fixing #132)
author Chris Cannam <chris.cannam@eecs.qmul.ac.uk>
date Tue, 24 May 2011 13:29:27 +0100
parents 2925975bdc9e
children 7ef46fb73b48 07eaf4e6003a
files src/hgrunner.cpp
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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()