mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 16:28:14 +00:00
Merge pull request #3305
d3102b1
DaemonManager: refactoring - drop singleton usage (xiphon)
This commit is contained in:
commit
04e3ac9200
3 changed files with 4 additions and 32 deletions
|
@ -47,23 +47,6 @@ namespace {
|
||||||
static const int DAEMON_START_TIMEOUT_SECONDS = 120;
|
static const int DAEMON_START_TIMEOUT_SECONDS = 120;
|
||||||
}
|
}
|
||||||
|
|
||||||
DaemonManager * DaemonManager::m_instance = nullptr;
|
|
||||||
QStringList DaemonManager::m_clArgs;
|
|
||||||
|
|
||||||
DaemonManager *DaemonManager::instance(const QStringList *args/* = nullptr*/)
|
|
||||||
{
|
|
||||||
if (!m_instance) {
|
|
||||||
m_instance = new DaemonManager;
|
|
||||||
// store command line arguments for later use
|
|
||||||
if (args != nullptr)
|
|
||||||
{
|
|
||||||
m_clArgs = *args;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const QString &dataDir, const QString &bootstrapNodeAddress, bool noSync /* = false*/)
|
bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const QString &dataDir, const QString &bootstrapNodeAddress, bool noSync /* = false*/)
|
||||||
{
|
{
|
||||||
if (!QFileInfo(m_monerod).isFile())
|
if (!QFileInfo(m_monerod).isFile())
|
||||||
|
@ -85,12 +68,6 @@ bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const
|
||||||
else if (nettype == NetworkType::STAGENET)
|
else if (nettype == NetworkType::STAGENET)
|
||||||
arguments << "--stagenet";
|
arguments << "--stagenet";
|
||||||
|
|
||||||
foreach (const QString &str, m_clArgs) {
|
|
||||||
qDebug() << QString(" [%1] ").arg(str);
|
|
||||||
if (!str.isEmpty())
|
|
||||||
arguments << str;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Custom startup flags for daemon
|
// Custom startup flags for daemon
|
||||||
foreach (const QString &str, flags.split(" ")) {
|
foreach (const QString &str, flags.split(" ")) {
|
||||||
qDebug() << QString(" [%1] ").arg(str);
|
qDebug() << QString(" [%1] ").arg(str);
|
||||||
|
|
|
@ -44,8 +44,8 @@ class DaemonManager : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
explicit DaemonManager(QObject *parent = 0);
|
||||||
static DaemonManager * instance(const QStringList *args = nullptr);
|
~DaemonManager();
|
||||||
|
|
||||||
Q_INVOKABLE bool start(const QString &flags, NetworkType::Type nettype, const QString &dataDir = "", const QString &bootstrapNodeAddress = "", bool noSync = false);
|
Q_INVOKABLE bool start(const QString &flags, NetworkType::Type nettype, const QString &dataDir = "", const QString &bootstrapNodeAddress = "", bool noSync = false);
|
||||||
Q_INVOKABLE void stopAsync(NetworkType::Type nettype, const QJSValue& callback);
|
Q_INVOKABLE void stopAsync(NetworkType::Type nettype, const QJSValue& callback);
|
||||||
|
@ -76,11 +76,6 @@ public slots:
|
||||||
void stateChanged(QProcess::ProcessState state);
|
void stateChanged(QProcess::ProcessState state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit DaemonManager(QObject *parent = 0);
|
|
||||||
~DaemonManager();
|
|
||||||
|
|
||||||
static DaemonManager * m_instance;
|
|
||||||
static QStringList m_clArgs;
|
|
||||||
std::unique_ptr<QProcess> m_daemon;
|
std::unique_ptr<QProcess> m_daemon;
|
||||||
QMutex m_daemonMutex;
|
QMutex m_daemonMutex;
|
||||||
QString m_monerod;
|
QString m_monerod;
|
||||||
|
|
|
@ -451,8 +451,8 @@ Verify update binary using 'shasum'-compatible (SHA256 algo) output signed by tw
|
||||||
|
|
||||||
// Exclude daemon manager from IOS
|
// Exclude daemon manager from IOS
|
||||||
#ifndef Q_OS_IOS
|
#ifndef Q_OS_IOS
|
||||||
DaemonManager * daemonManager = DaemonManager::instance();
|
DaemonManager daemonManager;
|
||||||
engine.rootContext()->setContextProperty("daemonManager", daemonManager);
|
engine.rootContext()->setContextProperty("daemonManager", &daemonManager);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("isWindows", isWindows);
|
engine.rootContext()->setContextProperty("isWindows", isWindows);
|
||||||
|
|
Loading…
Reference in a new issue