aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2020-02-19 22:17:04 -0500
committerluigi1111 <luigi1111w@gmail.com>2020-02-19 22:17:04 -0500
commitb4a65c52cc51fede20b80be0bf9f0e816c9ef752 (patch)
treeed01d375900baae6aa932e7028233030020cba61
parent386c5e3d305a97a47461d1d606850597fe17c317 (diff)
parent636ca1c41dc5fb56b9af4140f4896508de779e64 (diff)
downloadmonzero-gui-b4a65c52cc51fede20b80be0bf9f0e816c9ef752.tar.gz
monzero-gui-b4a65c52cc51fede20b80be0bf9f0e816c9ef752.tar.xz
monzero-gui-b4a65c52cc51fede20b80be0bf9f0e816c9ef752.zip
Merge pull request #2778
636ca1c DaemonManager: async stop, simple mode wizard - show splash on stop (xiphon)
-rw-r--r--main.qml15
-rw-r--r--src/daemon/DaemonManager.cpp22
-rw-r--r--src/daemon/DaemonManager.h2
3 files changed, 18 insertions, 21 deletions
diff --git a/main.qml b/main.qml
index c976bb41..eca1fb8f 100644
--- a/main.qml
+++ b/main.qml
@@ -679,9 +679,12 @@ ApplicationWindow {
daemonManager.start(flags, persistentSettings.nettype, persistentSettings.blockchainDataDir, bootstrapNodeAddress, noSync);
}
- function stopDaemon(){
+ function stopDaemon(callback){
appWindow.showProcessingSplash(qsTr("Waiting for daemon to stop..."))
- daemonManager.stop(persistentSettings.nettype);
+ daemonManager.stopAsync(persistentSettings.nettype, function(result) {
+ hideProcessingSplash();
+ callback(result);
+ });
}
function onDaemonStarted(){
@@ -695,8 +698,6 @@ ApplicationWindow {
simpleModeConnectionTimer.start();
}
function onDaemonStopped(){
- console.log("daemon stopped");
- hideProcessingSplash();
currentWallet.connected(true);
}
@@ -1928,8 +1929,7 @@ ApplicationWindow {
onClose();
}
confirmationDialog.onRejectedCallback = function() {
- daemonManager.stop(persistentSettings.nettype);
- onClose();
+ stopDaemon(onClose);
};
confirmationDialog.open();
}
@@ -1956,8 +1956,7 @@ ApplicationWindow {
// If daemon is running - prompt user before exiting
if(typeof daemonManager != "undefined" && daemonRunning) {
if (appWindow.walletMode == 0) {
- stopDaemon();
- closeAccepted();
+ stopDaemon(closeAccepted);
} else {
showDaemonIsRunningDialog(closeAccepted);
}
diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp
index 4b873dc5..215cd0a2 100644
--- a/src/daemon/DaemonManager.cpp
+++ b/src/daemon/DaemonManager.cpp
@@ -153,21 +153,19 @@ bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const
return true;
}
-bool DaemonManager::stop(NetworkType::Type nettype)
+void DaemonManager::stopAsync(NetworkType::Type nettype, const QJSValue& callback)
{
- QString message;
- sendCommand({"exit"}, nettype, message);
- qDebug() << message;
+ const auto feature = m_scheduler.run([this, nettype] {
+ QString message;
+ sendCommand({"exit"}, nettype, message);
- // Start stop watcher - Will kill if not shutting down
- m_scheduler.run([this, nettype] {
- if (stopWatcher(nettype))
- {
- emit daemonStopped();
- }
- });
+ return QJSValueList({stopWatcher(nettype)});
+ }, callback);
- return true;
+ if (!feature.first)
+ {
+ QJSValue(callback).call(QJSValueList({false}));
+ }
}
bool DaemonManager::startWatcher(NetworkType::Type nettype) const
diff --git a/src/daemon/DaemonManager.h b/src/daemon/DaemonManager.h
index 4bbd3133..774aecb3 100644
--- a/src/daemon/DaemonManager.h
+++ b/src/daemon/DaemonManager.h
@@ -45,7 +45,7 @@ public:
static DaemonManager * instance(const QStringList *args);
Q_INVOKABLE bool start(const QString &flags, NetworkType::Type nettype, const QString &dataDir = "", const QString &bootstrapNodeAddress = "", bool noSync = false);
- Q_INVOKABLE bool stop(NetworkType::Type nettype);
+ Q_INVOKABLE void stopAsync(NetworkType::Type nettype, const QJSValue& callback);
Q_INVOKABLE bool noSync() const noexcept;
// return true if daemon process is started