Prevent crash if export is dismissed before dialog closes
This commit is contained in:
@@ -37,7 +37,6 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) {
|
|||||||
int y = (screenGeometry.height() - d->height()) / 2;
|
int y = (screenGeometry.height() - d->height()) / 2;
|
||||||
d->move(x, y);
|
d->move(x, y);
|
||||||
connD->buttonBox->setEnabled(false);
|
connD->buttonBox->setEnabled(false);
|
||||||
d->show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ConnectionLoader::~ConnectionLoader() {
|
ConnectionLoader::~ConnectionLoader() {
|
||||||
@@ -54,6 +53,7 @@ void ConnectionLoader::loadConnection() {
|
|||||||
config = loadFromSettings();
|
config = loadFromSettings();
|
||||||
|
|
||||||
if (config.get() == nullptr) {
|
if (config.get() == nullptr) {
|
||||||
|
d->show();
|
||||||
// Nothing configured, show an error
|
// Nothing configured, show an error
|
||||||
auto explanation = QString()
|
auto explanation = QString()
|
||||||
% "A zcash.conf was not found on this machine.\n\n"
|
% "A zcash.conf was not found on this machine.\n\n"
|
||||||
@@ -98,11 +98,13 @@ void ConnectionLoader::refreshZcashdState(Connection* connection) {
|
|||||||
};
|
};
|
||||||
connection->doRPC(payload,
|
connection->doRPC(payload,
|
||||||
[=] (auto) {
|
[=] (auto) {
|
||||||
// Success
|
// Success, hide the dialog if it was shown.
|
||||||
d->hide();
|
d->hide();
|
||||||
rpc->setConnection(connection);
|
rpc->setConnection(connection);
|
||||||
},
|
},
|
||||||
[=] (auto reply, auto res) {
|
[=] (auto reply, auto res) {
|
||||||
|
d->show();
|
||||||
|
|
||||||
auto err = reply->error();
|
auto err = reply->error();
|
||||||
// Failed, see what it is.
|
// Failed, see what it is.
|
||||||
qDebug() << err << ":" << QString::fromStdString(res.dump());
|
qDebug() << err << ":" << QString::fromStdString(res.dump());
|
||||||
|
|||||||
@@ -499,7 +499,11 @@ void MainWindow::exportAllKeys() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Call the API
|
// Call the API
|
||||||
|
auto isDialogAlive = std::make_shared<bool>(true);
|
||||||
rpc->getAllPrivKeys([=] (auto privKeys) {
|
rpc->getAllPrivKeys([=] (auto privKeys) {
|
||||||
|
// Check to see if we are still showing.
|
||||||
|
if (! *isDialogAlive.get()) return;
|
||||||
|
|
||||||
QString allKeysTxt;
|
QString allKeysTxt;
|
||||||
for (auto keypair : privKeys) {
|
for (auto keypair : privKeys) {
|
||||||
allKeysTxt = allKeysTxt % keypair.second % " # addr=" % keypair.first % "\n";
|
allKeysTxt = allKeysTxt % keypair.second % " # addr=" % keypair.first % "\n";
|
||||||
@@ -509,10 +513,8 @@ void MainWindow::exportAllKeys() {
|
|||||||
pui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(true);
|
pui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
d.exec();
|
d.exec();
|
||||||
|
*isDialogAlive.get() = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupBalancesTab() {
|
void MainWindow::setupBalancesTab() {
|
||||||
|
|||||||
Reference in New Issue
Block a user