mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 20:20:02 +00:00
DaemonManager: add stateChanged()
This commit is contained in:
parent
760e01b50c
commit
8d19a03b68
2 changed files with 16 additions and 6 deletions
|
@ -61,6 +61,9 @@ bool DaemonManager::start()
|
||||||
m_daemon->start(process,arguments);
|
m_daemon->start(process,arguments);
|
||||||
bool started = m_daemon->waitForStarted();
|
bool started = m_daemon->waitForStarted();
|
||||||
|
|
||||||
|
// add state changed listener
|
||||||
|
connect(m_daemon,SIGNAL(stateChanged(QProcess::ProcessState)),this,SLOT(stateChanged(QProcess::ProcessState)));
|
||||||
|
|
||||||
if(!started){
|
if(!started){
|
||||||
qDebug() << "Daemon start error: " + m_daemon->errorString();
|
qDebug() << "Daemon start error: " + m_daemon->errorString();
|
||||||
} else {
|
} else {
|
||||||
|
@ -74,16 +77,22 @@ bool DaemonManager::stop()
|
||||||
{
|
{
|
||||||
if(initialized){
|
if(initialized){
|
||||||
qDebug() << "stopping daemon";
|
qDebug() << "stopping daemon";
|
||||||
m_daemon->terminate();
|
// we can't use QProcess::terminate() on windows console process
|
||||||
// Wait until stopped. Max 10 seconds
|
// write exit command to stdin
|
||||||
bool stopped = m_daemon->waitForFinished(10000);
|
m_daemon->write("exit\n");
|
||||||
if(stopped) emit daemonStopped();
|
|
||||||
return stopped;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DaemonManager::stateChanged(QProcess::ProcessState state)
|
||||||
|
{
|
||||||
|
qDebug() << "STATE CHANGED: " << state;
|
||||||
|
if(state == QProcess::NotRunning) {
|
||||||
|
emit daemonStopped();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DaemonManager::printOutput()
|
void DaemonManager::printOutput()
|
||||||
{
|
{
|
||||||
QByteArray byteArray = m_daemon->readAllStandardOutput();
|
QByteArray byteArray = m_daemon->readAllStandardOutput();
|
||||||
|
@ -111,7 +120,7 @@ bool DaemonManager::running() const
|
||||||
if(initialized){
|
if(initialized){
|
||||||
qDebug() << m_daemon->state();
|
qDebug() << m_daemon->state();
|
||||||
qDebug() << QProcess::NotRunning;
|
qDebug() << QProcess::NotRunning;
|
||||||
|
// m_daemon->write("status\n");
|
||||||
return m_daemon->state() > QProcess::NotRunning;
|
return m_daemon->state() > QProcess::NotRunning;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -28,6 +28,7 @@ public slots:
|
||||||
void printOutput();
|
void printOutput();
|
||||||
void printError();
|
void printError();
|
||||||
void closing();
|
void closing();
|
||||||
|
void stateChanged(QProcess::ProcessState state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue