Browse Source

prevent reentry on connection

recurring
adityapk00 6 years ago
parent
commit
49da8ed5ee
  1. 9
      src/rpc.cpp

9
src/rpc.cpp

@ -552,7 +552,7 @@ void RPC::getInfoThenRefresh(bool force) {
conn->doRPCIgnoreError(payload, [=](const json& reply) { conn->doRPCIgnoreError(payload, [=](const json& reply) {
auto progress = reply["verificationprogress"].get<double>(); auto progress = reply["verificationprogress"].get<double>();
bool isSyncing = progress < 0.995; // 99.59% bool isSyncing = progress < 0.9999; // 99.99%
int blockNumber = reply["blocks"].get<json::number_unsigned_t>(); int blockNumber = reply["blocks"].get<json::number_unsigned_t>();
int estimatedheight = 0; int estimatedheight = 0;
@ -601,9 +601,14 @@ void RPC::getInfoThenRefresh(bool force) {
}, [=](QNetworkReply* reply, const json&) { }, [=](QNetworkReply* reply, const json&) {
// zcashd has probably disappeared. // zcashd has probably disappeared.
this->noConnection(); this->noConnection();
if (prevCallSucceeded) { // show error only first time
// Prevent multiple dialog boxes, because these are called async
static bool shown = false;
if (!shown && prevCallSucceeded) { // show error only first time
shown = true;
QMessageBox::critical(main, "Connection Error", "There was an error connecting to zcashd. The error was: \n\n" QMessageBox::critical(main, "Connection Error", "There was an error connecting to zcashd. The error was: \n\n"
+ reply->errorString(), QMessageBox::StandardButton::Ok); + reply->errorString(), QMessageBox::StandardButton::Ok);
shown = false;
} }
prevCallSucceeded = false; prevCallSucceeded = false;

Loading…
Cancel
Save