Prevent crash if export is dismissed before dialog closes

This commit is contained in:
Aditya Kulkarni
2018-11-01 23:21:38 -07:00
parent 8e363649f6
commit 2c7c57e39b
2 changed files with 10 additions and 6 deletions

View File

@@ -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() {