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