fix memory leaks
This commit is contained in:
@@ -7,22 +7,7 @@
|
|||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
using json = nlohmann::json;
|
using json = nlohmann::json;
|
||||||
/*
|
|
||||||
class LoadingDialog : public QDialog {
|
|
||||||
//Q_OBJECT
|
|
||||||
public:
|
|
||||||
LoadingDialog(QWidget* parent);
|
|
||||||
~LoadingDialog();
|
|
||||||
public slots:
|
|
||||||
void reject();
|
|
||||||
};
|
|
||||||
|
|
||||||
LoadingDialog::LoadingDialog(QWidget* parent) : QDialog(parent) {}
|
|
||||||
LoadingDialog::~LoadingDialog() {}
|
|
||||||
void LoadingDialog::reject() {
|
|
||||||
//event->ignore();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) {
|
ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) {
|
||||||
this->main = main;
|
this->main = main;
|
||||||
this->rpc = rpc;
|
this->rpc = rpc;
|
||||||
@@ -61,7 +46,7 @@ void ConnectionLoader::loadConnection() {
|
|||||||
% "please set the host/port and user/password in the File->Settings menu.";
|
% "please set the host/port and user/password in the File->Settings menu.";
|
||||||
|
|
||||||
showError(explanation);
|
showError(explanation);
|
||||||
rpc->setConnection(nullptr);
|
doRPCSetConnection(nullptr);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -71,6 +56,11 @@ void ConnectionLoader::loadConnection() {
|
|||||||
refreshZcashdState(connection);
|
refreshZcashdState(connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectionLoader::doRPCSetConnection(Connection* conn) {
|
||||||
|
rpc->setConnection(conn);
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
Connection* ConnectionLoader::makeConnection(std::shared_ptr<ConnectionConfig> config) {
|
Connection* ConnectionLoader::makeConnection(std::shared_ptr<ConnectionConfig> config) {
|
||||||
QNetworkAccessManager* client = new QNetworkAccessManager(main);
|
QNetworkAccessManager* client = new QNetworkAccessManager(main);
|
||||||
|
|
||||||
@@ -100,7 +90,7 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) {
|
|||||||
[=] (auto) {
|
[=] (auto) {
|
||||||
// Success, hide the dialog if it was shown.
|
// Success, hide the dialog if it was shown.
|
||||||
d->hide();
|
d->hide();
|
||||||
rpc->setConnection(connection);
|
doRPCSetConnection(connection);
|
||||||
},
|
},
|
||||||
[=] (auto reply, auto res) {
|
[=] (auto reply, auto res) {
|
||||||
d->show();
|
d->show();
|
||||||
@@ -148,16 +138,6 @@ void ConnectionLoader::showError(QString explanation) {
|
|||||||
connD->buttonBox->setEnabled(true);
|
connD->buttonBox->setEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
int ConnectionLoader::getProgressFromStatus(QString status) {
|
|
||||||
if (status.startsWith("Loading block")) return 20;
|
|
||||||
if (status.startsWith("Verifying")) return 40;
|
|
||||||
if (status.startsWith("Loading Wallet")) return 60;
|
|
||||||
if (status.startsWith("Activating")) return 80;
|
|
||||||
if (status.startsWith("Rescanning")) return 90;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try to automatically detect a zcash.conf file in the correct location and load parameters
|
* Try to automatically detect a zcash.conf file in the correct location and load parameters
|
||||||
@@ -248,10 +228,11 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::loadFromSettings() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************************
|
||||||
|
* Connection Class
|
||||||
|
************************************************************************************/
|
||||||
Connection::Connection(MainWindow* m, QNetworkAccessManager* c, QNetworkRequest* r, std::shared_ptr<ConnectionConfig> conf) {
|
Connection::Connection(MainWindow* m, QNetworkAccessManager* c, QNetworkRequest* r,
|
||||||
|
std::shared_ptr<ConnectionConfig> conf) {
|
||||||
this->restclient = c;
|
this->restclient = c;
|
||||||
this->request = r;
|
this->request = r;
|
||||||
this->config = conf;
|
this->config = conf;
|
||||||
@@ -263,8 +244,6 @@ Connection::~Connection() {
|
|||||||
delete request;
|
delete request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void Connection::doRPC(const json& payload, const std::function<void(json)>& cb,
|
void Connection::doRPC(const json& payload, const std::function<void(json)>& cb,
|
||||||
const std::function<void(QNetworkReply*, const json&)>& ne) {
|
const std::function<void(QNetworkReply*, const json&)>& ne) {
|
||||||
QNetworkReply *reply = restclient->post(*request, QByteArray::fromStdString(payload.dump()));
|
QNetworkReply *reply = restclient->post(*request, QByteArray::fromStdString(payload.dump()));
|
||||||
@@ -315,4 +294,4 @@ void Connection::showTxError(const QString& error) {
|
|||||||
+ error);
|
+ error);
|
||||||
|
|
||||||
msg.exec();
|
msg.exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,8 @@ private:
|
|||||||
|
|
||||||
void showError(QString explanation);
|
void showError(QString explanation);
|
||||||
|
|
||||||
|
void doRPCSetConnection(Connection* conn);
|
||||||
|
|
||||||
QDialog* d;
|
QDialog* d;
|
||||||
Ui_ConnectionDialog* connD;
|
Ui_ConnectionDialog* connD;
|
||||||
|
|
||||||
@@ -122,4 +124,4 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -261,6 +261,7 @@ void RPC::getAllPrivKeys(const std::function<void(QList<QPair<QString, QString>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
fnCombineTwoLists(allTKeys);
|
fnCombineTwoLists(allTKeys);
|
||||||
|
delete privkeys;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -677,6 +678,7 @@ void RPC::refreshSentZTrans() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
transactionsTableModel->addZSentData(newSentZTxs);
|
transactionsTableModel->addZSentData(newSentZTxs);
|
||||||
|
delete txidList;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ TxTableModel::TxTableModel(QObject *parent)
|
|||||||
|
|
||||||
TxTableModel::~TxTableModel() {
|
TxTableModel::~TxTableModel() {
|
||||||
delete modeldata;
|
delete modeldata;
|
||||||
|
delete tTrans;
|
||||||
|
delete zsTrans;
|
||||||
|
delete zrTrans;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TxTableModel::addZSentData(const QList<TransactionItem>& data) {
|
void TxTableModel::addZSentData(const QList<TransactionItem>& data) {
|
||||||
@@ -159,4 +162,4 @@ QString TxTableModel::getTxId(int row) {
|
|||||||
|
|
||||||
QString TxTableModel::getMemo(int row) {
|
QString TxTableModel::getMemo(int row) {
|
||||||
return modeldata->at(row).memo;
|
return modeldata->at(row).memo;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user