From 8dfa79ec58898a1b9522d1f2e86a73aab346319f Mon Sep 17 00:00:00 2001 From: Jaquee Date: Fri, 25 Nov 2016 21:14:52 +0100 Subject: [PATCH] Shutdown daemon and close wallet properly on app exit --- main.cpp | 8 ++++++++ main.qml | 15 ++++++++------- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/main.cpp b/main.cpp index 21ab9da5..ebae384f 100644 --- a/main.cpp +++ b/main.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "clipboardAdapter.h" #include "filter.h" #include "oscursor.h" @@ -110,6 +111,13 @@ int main(int argc, char *argv[]) engine.rootContext()->setContextProperty("daemonManager", DaemonManager::instance(QCoreApplication::arguments())); + DaemonManager * daemonManager = DaemonManager::instance(QCoreApplication::arguments()); + QObject::connect(&app, SIGNAL(aboutToQuit()), daemonManager, SLOT(closing())); + engine.rootContext()->setContextProperty("daemonManager", daemonManager); + + +>>>>>>> cc05e1a... Shutdown daemon and close wallet properly on app exit + // export to QML monero accounts root directory // wizard is talking about where // to save the wallet file (.keys, .bin), they have to be user-accessible for diff --git a/main.qml b/main.qml index 78e3ccac..f51ffded 100644 --- a/main.qml +++ b/main.qml @@ -1053,12 +1053,13 @@ ApplicationWindow { } } onClosing: { - // Close and save to disk on app close - if (currentWallet != undefined) { - walletManager.closeWallet(currentWallet); - currentWallet = undefined - } - // Stop daemon - daemonManager.stop(); + // Make sure wallet is closed before app exit (~Wallet() isn't always invoked) + // Daemon shutdown is handled with signal/slot in main.cpp + if (currentWallet != undefined) { + walletManager.closeWallet(currentWallet); + currentWallet = undefined + } + // Stop daemon + daemonManager.stop(); } }