Updated wallet close behaviour

This commit is contained in:
Jaquee 2016-12-15 13:18:04 +01:00
parent a16b9a8ffe
commit 143da2c390
No known key found for this signature in database
GPG key ID: 384E52B09F45DC39
2 changed files with 18 additions and 15 deletions

View file

@ -135,7 +135,7 @@ ApplicationWindow {
// If currentWallet exists, we're just switching daemon - close/reopen wallet // If currentWallet exists, we're just switching daemon - close/reopen wallet
if (typeof currentWallet !== "undefined" && currentWallet !== null) { if (typeof currentWallet !== "undefined" && currentWallet !== null) {
console.log("Daemon change - closing " + currentWallet) console.log("Daemon change - closing " + currentWallet)
walletManager.closeWalletAsync(); closeWallet();
currentWallet = undefined currentWallet = undefined
} else { } else {
@ -170,13 +170,9 @@ ApplicationWindow {
} }
} }
function closeWallet() {
// Disconnect all listeners
function connectWallet(wallet) {
showProcessingSplash("Please wait...")
currentWallet = wallet
// Disconnect before connecting
currentWallet.refreshed.disconnect(onWalletRefresh) currentWallet.refreshed.disconnect(onWalletRefresh)
currentWallet.updated.disconnect(onWalletUpdate) currentWallet.updated.disconnect(onWalletUpdate)
currentWallet.newBlock.disconnect(onWalletNewBlock) currentWallet.newBlock.disconnect(onWalletNewBlock)
@ -188,6 +184,14 @@ ApplicationWindow {
middlePanel.sweepUnmixableClicked.disconnect(handleSweepUnmixable); middlePanel.sweepUnmixableClicked.disconnect(handleSweepUnmixable);
middlePanel.checkPaymentClicked.disconnect(handleCheckPayment); middlePanel.checkPaymentClicked.disconnect(handleCheckPayment);
walletManager.closeWalletAsync();
currentWallet = undefined;
}
function connectWallet(wallet) {
showProcessingSplash("Please wait...")
currentWallet = wallet
// connect handlers // connect handlers
currentWallet.refreshed.connect(onWalletRefresh) currentWallet.refreshed.connect(onWalletRefresh)
currentWallet.updated.connect(onWalletUpdate) currentWallet.updated.connect(onWalletUpdate)
@ -222,7 +226,7 @@ ApplicationWindow {
if (appWindow.password === '') { if (appWindow.password === '') {
console.error("Error opening wallet with empty password: ", wallet.errorString); console.error("Error opening wallet with empty password: ", wallet.errorString);
console.log("closing wallet async : " + wallet.address) console.log("closing wallet async : " + wallet.address)
walletManager.closeWalletAsync() closeWallet();
currentWallet = undefined currentWallet = undefined
// try to open wallet with password; // try to open wallet with password;
@ -235,7 +239,7 @@ ApplicationWindow {
informationPopup.text = qsTr("Couldn't open wallet: ") + wallet.errorString; informationPopup.text = qsTr("Couldn't open wallet: ") + wallet.errorString;
informationPopup.icon = StandardIcon.Critical informationPopup.icon = StandardIcon.Critical
console.log("closing wallet async : " + wallet.address) console.log("closing wallet async : " + wallet.address)
walletManager.closeWalletAsync(); closeWallet();
currentWallet = undefined currentWallet = undefined
informationPopup.open() informationPopup.open()
informationPopup.onCloseCallback = function() { informationPopup.onCloseCallback = function() {
@ -611,8 +615,7 @@ ApplicationWindow {
function showWizard(){ function showWizard(){
walletInitialized = false; walletInitialized = false;
splashCounter = 0; splashCounter = 0;
walletManager.closeWalletAsync(); closeWallet();
currentWallet = undefined
wizard.restart(); wizard.restart();
rootItem.state = "wizard" rootItem.state = "wizard"
} }
@ -1033,7 +1036,7 @@ ApplicationWindow {
} }
onClosing: { onClosing: {
// Close wallet // Close wallet non async on exit
walletManager.closeWallet(); walletManager.closeWallet();
// Stop daemon // Stop daemon
daemonManager.stop(); daemonManager.stop();

View file

@ -480,7 +480,7 @@ Wallet::~Wallet()
qDebug("~Wallet: Closing wallet"); qDebug("~Wallet: Closing wallet");
delete m_history; delete m_history;
//Monero::WalletManagerFactory::getWalletManager()->closeWallet(m_walletImpl);
Monero::WalletManagerFactory::getWalletManager()->closeWallet(m_walletImpl); delete m_walletImpl;
qDebug("m_walletImpl deleted");
} }