From 2bd1692a2f9da42b52ffb0e415a33515c69b5acb Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 5 Jan 2018 01:59:01 +0100 Subject: [PATCH] Commands: use monospaced font to view the log --- sdrbase/commands/command.cpp | 27 ++++++++++++++----- sdrgui/gui/commandoutputdialog.ui | 5 ++++ .../sdrangel/examples/devicesets_config.py | 0 3 files changed, 25 insertions(+), 7 deletions(-) mode change 100644 => 100755 swagger/sdrangel/examples/devicesets_config.py diff --git a/sdrbase/commands/command.cpp b/sdrbase/commands/command.cpp index b2acfc825..09cffa187 100644 --- a/sdrbase/commands/command.cpp +++ b/sdrbase/commands/command.cpp @@ -64,7 +64,19 @@ Command::Command(const Command& command) : } Command::~Command() -{} +{ + if (m_currentProcess) + { +#if QT_VERSION < 0x051000 + disconnect(m_currentProcess, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); +#else + disconnect(m_currentProcess, SIGNAL(errorOccurred(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError))); +#endif + disconnect(m_currentProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus))); + disconnect(m_currentProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState))); + m_currentProcess->deleteLater(); + } +} void Command::resetToDefaults() { @@ -235,6 +247,7 @@ const QString& Command::getLastProcessLog() const void Command::processStateChanged(QProcess::ProcessState newState) { + qDebug("Command::processStateChanged: %d", newState); if (newState == QProcess::Running) { m_currentProcessPid = m_currentProcess->processId(); } @@ -244,7 +257,7 @@ void Command::processStateChanged(QProcess::ProcessState newState) void Command::processError(QProcess::ProcessError error) { - //qDebug("Command::processError: %d state: %d", error, m_currentProcessState); + qDebug("Command::processError: %d state: %d", error, m_currentProcessState); gettimeofday(&m_currentProcessFinishTimeStamp, 0); m_currentProcessError = error; m_isInError = true; @@ -261,14 +274,14 @@ void Command::processError(QProcess::ProcessError error) disconnect(m_currentProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus))); disconnect(m_currentProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState))); - delete m_currentProcess; - m_currentProcess = 0; + m_currentProcess->deleteLater(); // make sure other threads can still access it until all events have been processed + m_currentProcess = 0; // for this thread it can assume it was deleted } } void Command::processFinished(int exitCode, QProcess::ExitStatus exitStatus) { - //qDebug("Command::processFinished: (%d) %d", exitCode, exitStatus); + qDebug("Command::processFinished: (%d) %d", exitCode, exitStatus); gettimeofday(&m_currentProcessFinishTimeStamp, 0); m_currentProcessExitCode = exitCode; m_currentProcessExitStatus = exitStatus; @@ -283,6 +296,6 @@ void Command::processFinished(int exitCode, QProcess::ExitStatus exitStatus) disconnect(m_currentProcess, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(processFinished(int, QProcess::ExitStatus))); disconnect(m_currentProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState))); - delete m_currentProcess; - m_currentProcess = 0; + m_currentProcess->deleteLater(); // make sure other threads can still access it until all events have been processed + m_currentProcess = 0; // for this thread it can assume it was deleted } diff --git a/sdrgui/gui/commandoutputdialog.ui b/sdrgui/gui/commandoutputdialog.ui index 35c48628d..061b75d6b 100644 --- a/sdrgui/gui/commandoutputdialog.ui +++ b/sdrgui/gui/commandoutputdialog.ui @@ -278,6 +278,11 @@ true + + + Monospace + + Output log (stdout + stderr) diff --git a/swagger/sdrangel/examples/devicesets_config.py b/swagger/sdrangel/examples/devicesets_config.py old mode 100644 new mode 100755