mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-22 19:49:34 +00:00
code clean up and wallet close consistency
This commit is contained in:
parent
ead9bd70be
commit
eb97bda3a3
3 changed files with 20 additions and 61 deletions
77
main.qml
77
main.qml
|
@ -109,30 +109,8 @@ ApplicationWindow {
|
|||
ctrlPressed = false
|
||||
}
|
||||
|
||||
function mousePressed(obj, mouseX, mouseY) {
|
||||
// if(obj.objectName === "appWindow")
|
||||
// obj = rootItem
|
||||
|
||||
// var tmp = rootItem.mapFromItem(obj, mouseX, mouseY)
|
||||
// if(tmp !== undefined) {
|
||||
// mouseX = tmp.x
|
||||
// mouseY = tmp.y
|
||||
// }
|
||||
|
||||
// if(currentItem !== undefined) {
|
||||
// var tmp_x = rootItem.mapToItem(currentItem, mouseX, mouseY).x
|
||||
// var tmp_y = rootItem.mapToItem(currentItem, mouseX, mouseY).y
|
||||
|
||||
// if(!currentItem.containsPoint(tmp_x, tmp_y)) {
|
||||
// currentItem.hide()
|
||||
// currentItem = undefined
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
function mouseReleased(obj, mouseX, mouseY) {
|
||||
|
||||
}
|
||||
function mousePressed(obj, mouseX, mouseY) {}
|
||||
function mouseReleased(obj, mouseX, mouseY) {}
|
||||
|
||||
function openWalletFromFile(){
|
||||
persistentSettings.restore_height = 0
|
||||
|
@ -153,22 +131,10 @@ ApplicationWindow {
|
|||
translationManager.setLanguage(locale.split("_")[0]);
|
||||
}
|
||||
|
||||
// disconnect handlers before connecting
|
||||
middlePanel.paymentClicked.disconnect(handlePayment);
|
||||
// TODO: remove if statement when PR #111 is merged
|
||||
if(typeof(handleCheckPayment) !== "undefined") {
|
||||
middlePanel.checkPaymentClicked.disconnect(handleCheckPayment);
|
||||
}
|
||||
middlePanel.paymentClicked.connect(handlePayment);
|
||||
middlePanel.sweepUnmixableClicked.connect(handleSweepUnmixable);
|
||||
// basicPanel.paymentClicked.connect(handlePayment);
|
||||
middlePanel.checkPaymentClicked.connect(handleCheckPayment);
|
||||
|
||||
// currentWallet is defined on daemon address change - close/reopen
|
||||
// TODO: strict comparison here (!==) causes crash after passwordDialog on previously crashed unsynced wallets
|
||||
if (currentWallet != undefined) {
|
||||
console.log("closing currentWallet")
|
||||
walletManager.closeWallet(currentWallet);
|
||||
// If currentWallet exists, we're just switching daemon - close/reopen wallet
|
||||
if (typeof currentWallet !== "undefined" && currentWallet !== null) {
|
||||
console.log("Daemon change - closing " + currentWallet)
|
||||
walletManager.closeWalletAsync();
|
||||
} else {
|
||||
|
||||
// set page to transfer if not changing daemon
|
||||
|
@ -216,7 +182,11 @@ ApplicationWindow {
|
|||
currentWallet.moneyReceived.disconnect(onWalletMoneyReceived)
|
||||
currentWallet.transactionCreated.disconnect(onTransactionCreated)
|
||||
currentWallet.connectionStatusChanged.disconnect(onWalletConnectionStatusChanged)
|
||||
middlePanel.paymentClicked.disconnect(handlePayment);
|
||||
middlePanel.sweepUnmixableClicked.disconnect(handleSweepUnmixable);
|
||||
middlePanel.checkPaymentClicked.disconnect(handleCheckPayment);
|
||||
|
||||
// connect handlers
|
||||
currentWallet.refreshed.connect(onWalletRefresh)
|
||||
currentWallet.updated.connect(onWalletUpdate)
|
||||
currentWallet.newBlock.connect(onWalletNewBlock)
|
||||
|
@ -224,7 +194,9 @@ ApplicationWindow {
|
|||
currentWallet.moneyReceived.connect(onWalletMoneyReceived)
|
||||
currentWallet.transactionCreated.connect(onTransactionCreated)
|
||||
currentWallet.connectionStatusChanged.connect(onWalletConnectionStatusChanged)
|
||||
|
||||
middlePanel.paymentClicked.connect(handlePayment);
|
||||
middlePanel.sweepUnmixableClicked.connect(handleSweepUnmixable);
|
||||
middlePanel.checkPaymentClicked.connect(handleCheckPayment);
|
||||
|
||||
console.log("initializing with daemon address: ", persistentSettings.daemon_address)
|
||||
console.log("Recovering from seed: ", persistentSettings.is_recovering)
|
||||
|
@ -248,7 +220,7 @@ ApplicationWindow {
|
|||
if (appWindow.password === '') {
|
||||
console.error("Error opening wallet with empty password: ", wallet.errorString);
|
||||
console.log("closing wallet async : " + wallet.address)
|
||||
walletManager.closeWalletAsync(wallet)
|
||||
walletManager.closeWalletAsync()
|
||||
// try to open wallet with password;
|
||||
passwordDialog.open(wallet.path);
|
||||
} else {
|
||||
|
@ -259,7 +231,7 @@ ApplicationWindow {
|
|||
informationPopup.text = qsTr("Couldn't open wallet: ") + wallet.errorString;
|
||||
informationPopup.icon = StandardIcon.Critical
|
||||
console.log("closing wallet async : " + wallet.address)
|
||||
walletManager.closeWalletAsync(wallet);
|
||||
walletManager.closeWalletAsync();
|
||||
informationPopup.open()
|
||||
informationPopup.onCloseCallback = function() {
|
||||
passwordDialog.open(wallet.path)
|
||||
|
@ -619,7 +591,6 @@ ApplicationWindow {
|
|||
middlePanel.enabled = enable;
|
||||
leftPanel.enabled = enable;
|
||||
rightPanel.enabled = enable;
|
||||
// basicPanel.enabled = enable;
|
||||
}
|
||||
|
||||
function showProcessingSplash(message) {
|
||||
|
@ -640,14 +611,9 @@ ApplicationWindow {
|
|||
function showWizard(){
|
||||
walletInitialized = false;
|
||||
splashCounter = 0;
|
||||
// we can't close async here. Gui crashes if wallet is open
|
||||
if (currentWallet != undefined) {
|
||||
walletManager.closeWallet(currentWallet);
|
||||
currentWallet = undefined
|
||||
}
|
||||
walletManager.closeWalletAsync();
|
||||
wizard.restart();
|
||||
rootItem.state = "wizard"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -702,8 +668,6 @@ ApplicationWindow {
|
|||
property bool is_recovering : false
|
||||
}
|
||||
|
||||
// TODO: replace with customized popups
|
||||
|
||||
// Information dialog
|
||||
StandardDialog {
|
||||
// dynamically change onclose handler
|
||||
|
@ -748,7 +712,6 @@ ApplicationWindow {
|
|||
id: passwordDialog
|
||||
|
||||
onAccepted: {
|
||||
appWindow.currentWallet = null
|
||||
appWindow.initialize();
|
||||
}
|
||||
onRejected: {
|
||||
|
@ -1036,12 +999,8 @@ ApplicationWindow {
|
|||
}
|
||||
}
|
||||
onClosing: {
|
||||
// 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
|
||||
}
|
||||
// Close wallet
|
||||
walletManager.closeWallet();
|
||||
// Stop daemon
|
||||
daemonManager.stop();
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ Item {
|
|||
|
||||
// Always delete the wallet object before creating new - we could be stepping back from recovering wallet
|
||||
if (typeof settingsObject.wallet !== 'undefined') {
|
||||
settingsObject.wallet.destroy()
|
||||
walletManager.closeWallet()
|
||||
console.log("deleting wallet")
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ Item {
|
|||
settingsObject['wallet'] = wallet;
|
||||
settingsObject['is_recovering'] = true;
|
||||
} else {
|
||||
walletManager.closeWallet(wallet);
|
||||
walletManager.closeWallet();
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue