1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-21 07:41:46 -05:00

Support compilation on Qt platforms that don't support processes (i.e. WebAssembly).

This commit is contained in:
srcejon 2024-11-06 12:11:49 +00:00
parent 2abe88368b
commit 8ed7972dce
8 changed files with 41 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#include "util/timeutil.h"
Command::Command() :
#if QT_CONFIG(process)
m_currentProcess(nullptr),
m_currentProcessState(QProcess::NotRunning),
m_isInError(false),
@ -35,6 +36,7 @@ Command::Command() :
m_hasExited(false),
m_currentProcessExitCode(0),
m_currentProcessExitStatus(QProcess::NormalExit),
#endif
m_currentProcessPid(0)
{
m_currentProcessStartTimeStampms = 0;
@ -53,6 +55,7 @@ Command::Command(const Command& command) :
m_keyModifiers(command.m_keyModifiers),
m_associateKey(command.m_associateKey),
m_release(command.m_release),
#if QT_CONFIG(process)
m_currentProcess(nullptr),
m_currentProcessState(QProcess::NotRunning),
m_isInError(false),
@ -60,6 +63,7 @@ Command::Command(const Command& command) :
m_hasExited(false),
m_currentProcessExitCode(0),
m_currentProcessExitStatus(QProcess::NormalExit),
#endif
m_currentProcessPid(0)
{
m_currentProcessStartTimeStampms = 0;
@ -68,6 +72,7 @@ Command::Command(const Command& command) :
Command::~Command()
{
#if QT_CONFIG(process)
if (m_currentProcess)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
@ -79,6 +84,7 @@ Command::~Command()
disconnect(m_currentProcess, SIGNAL(stateChanged(QProcess::ProcessState)), this, SLOT(processStateChanged(QProcess::ProcessState)));
m_currentProcess->deleteLater();
}
#endif
}
void Command::resetToDefaults()
@ -164,6 +170,7 @@ QString Command::getKeyLabel() const
void Command::run(const QString& apiAddress, int apiPort, int deviceSetIndex)
{
#if QT_CONFIG(process)
if (m_currentProcess)
{
qWarning("Command::run: process already running");
@ -212,17 +219,22 @@ void Command::run(const QString& apiAddress, int apiPort, int deviceSetIndex)
QStringList allArgs = args.split(" ", QString::SkipEmptyParts);
#endif
m_currentProcess->start(m_command, allArgs);
#endif
}
void Command::kill()
{
#if QT_CONFIG(process)
if (m_currentProcess)
{
qDebug("Command::kill: %lld", m_currentProcessPid);
m_currentProcess->kill();
}
#endif
}
#if QT_CONFIG(process)
QProcess::ProcessState Command::getLastProcessState() const
{
return m_currentProcessState;
@ -307,3 +319,4 @@ void Command::processFinished(int exitCode, QProcess::ExitStatus exitStatus)
m_currentProcess->deleteLater(); // make sure other threads can still access it until all events have been processed
m_currentProcess = nullptr; // for this thread it can assume it was deleted
}
#endif /* QT_CONFIG(process) */

View File

@ -62,10 +62,12 @@ public:
void run(const QString& apiAddress, int apiPort, int deviceSetIndex = 0);
void kill();
#if QT_CONFIG(process)
QProcess::ProcessState getLastProcessState() const;
bool getLastProcessError(QProcess::ProcessError& error) const;
bool getLastProcessExit(int& exitCode, QProcess::ExitStatus& exitStatus) const;
const QString& getLastProcessLog() const;
#endif
uint64_t getLastProcessStartTimestampms() const { return m_currentProcessStartTimeStampms; }
uint64_t getLastProcessFinishTimestampms() const { return m_currentProcessFinishTimeStampms; }
const QString& getLastProcessCommandLine() const { return m_currentProcessCommandLine; }
@ -102,6 +104,7 @@ private:
Qt::KeyboardModifiers m_keyModifiers;
bool m_associateKey;
bool m_release;
#if QT_CONFIG(process)
QProcess *m_currentProcess;
QProcess::ProcessState m_currentProcessState;
bool m_isInError;
@ -109,6 +112,7 @@ private:
bool m_hasExited;
int m_currentProcessExitCode;
QProcess::ExitStatus m_currentProcessExitStatus;
#endif
QString m_log;
uint64_t m_currentProcessStartTimeStampms;
uint64_t m_currentProcessFinishTimeStampms;
@ -116,9 +120,11 @@ private:
qint64 m_currentProcessPid;
private slots:
#if QT_CONFIG(process)
void processStateChanged(QProcess::ProcessState newState);
void processError(QProcess::ProcessError error);
void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
#endif
};
Q_DECLARE_METATYPE(const Command*);

View File

@ -22,6 +22,8 @@
#include <QDateTime>
#if QT_CONFIG(process)
CommandOutputDialog::CommandOutputDialog(Command& command, QWidget* parent) :
QDialog(parent),
ui(new Ui::CommandOutputDialog),
@ -167,3 +169,4 @@ void CommandOutputDialog::on_processKill_toggled(bool checked)
}
}
#endif // QT_CONFIG(process)

View File

@ -24,6 +24,8 @@
#include <QDialog>
#include <QProcess>
#if QT_CONFIG(process)
#include "export.h"
namespace Ui {
@ -54,5 +56,6 @@ private slots:
void on_processKill_toggled(bool checked);
};
#endif
#endif /* SDRGUI_GUI_COMMANDOUTPUTDIALOG_H_ */

View File

@ -29,6 +29,8 @@
#include "commandsdialog.h"
#include "ui_commandsdialog.h"
#if QT_CONFIG(process)
CommandsDialog::CommandsDialog(QWidget* parent) :
QDialog(parent),
ui(new Ui::CommandsDialog),
@ -309,3 +311,5 @@ QTreeWidgetItem* CommandsDialog::addCommandToTree(const Command* command)
//updatePresetControls();
return item;
}
#endif // QT_CONFIG(process)

View File

@ -25,6 +25,8 @@
#include "export.h"
#if QT_CONFIG(process)
class CommandKeyReceiver;
namespace Ui {
@ -66,4 +68,6 @@ private slots:
void on_commandKeyboardConnect_toggled(bool checked);
};
#endif // QT_CONFIG(process)
#endif // SDRGUI_GUI_COMMANDSDIALOG_H_

View File

@ -24,6 +24,8 @@
#include "fftwisdomdialog.h"
#include "ui_fftwisdomdialog.h"
#if QT_CONFIG(process)
FFTWisdomDialog::FFTWisdomDialog(QProcess *process, QWidget* parent) :
QDialog(parent),
ui(new Ui::FFTWisdomDialog),
@ -132,3 +134,5 @@ void FFTWisdomDialog::updateArguments(int fftMaxLog2, bool includeReverse)
qDebug("FFTWisdomDialog::updateArguments: %s %s", qPrintable(m_fftwExecPath), qPrintable(argStr));
ui->fftwCommand->setText(m_fftwExecPath + " " + argStr);
}
#endif // QT_CONFIG(process)

View File

@ -25,6 +25,8 @@
#include "export.h"
#if QT_CONFIG(process)
namespace Ui {
class FFTWisdomDialog;
}
@ -55,5 +57,7 @@ private:
QProcess *m_process;
};
#endif
#endif // SDRGUI_GUI_FFTWISDOMDIALOG_H_