Mercurial > hg > octave-terminal
changeset 13332:ff3206f87e4d
Octave restarts when process exits.
author | Jacob Dawid <jacob.dawid@googlemail.com> |
---|---|
date | Tue, 05 Apr 2011 17:15:01 +0200 |
parents | 30469264a58f |
children | 5a6afd0e5213 |
files | gui//client.cpp gui//client.h gui//mainwindow.cpp |
diffstat | 3 files changed, 25 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gui//client.cpp +++ b/gui//client.cpp @@ -1,8 +1,11 @@ #include "client.h" -Client::Client(QString command) { - m_process.start(command, QProcess::ReadWrite); +Client::Client(QString command) + : m_command(command) { + m_process.start(m_command, QProcess::ReadWrite); connect(&m_process, SIGNAL(readyRead()), this, SLOT(reemitDataAvailable())); + connect(&m_process, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(handleProcessStatusChange(QProcess::ProcessState))); + connect(&m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(handleProcessFinished(int,QProcess::ExitStatus))); } void Client::send(QString content) { @@ -27,3 +30,17 @@ emit errorAvailable(); } +void Client::handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { + m_process.start(m_command, QProcess::ReadWrite); +} + +void Client::handleProcessStatusChange(QProcess::ProcessState processState) { + switch(processState) { + case QProcess::NotRunning: + break; + case QProcess::Starting: + break; + case QProcess::Running: + break; + }; +}
--- a/gui//client.h +++ b/gui//client.h @@ -18,6 +18,7 @@ signals: void dataAvailable(); void errorAvailable(); + void lostConnection(); protected: Client(QString command); @@ -25,8 +26,11 @@ private slots: void reemitDataAvailable(); void reemitErrorAvailable(); + void handleProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); + void handleProcessStatusChange(QProcess::ProcessState processState); private: + QString m_command; QProcess m_process; QMutex m_clientInRequest; };