From 49da8ed5ee1ff136923c64b2898b70ea365251df Mon Sep 17 00:00:00 2001 From: adityapk00 Date: Fri, 23 Nov 2018 11:44:56 -0800 Subject: [PATCH] prevent reentry on connection --- src/rpc.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index 942b806..3ff3eb0 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -552,7 +552,7 @@ void RPC::getInfoThenRefresh(bool force) { conn->doRPCIgnoreError(payload, [=](const json& reply) { auto progress = reply["verificationprogress"].get(); - bool isSyncing = progress < 0.995; // 99.59% + bool isSyncing = progress < 0.9999; // 99.99% int blockNumber = reply["blocks"].get(); int estimatedheight = 0; @@ -601,9 +601,14 @@ void RPC::getInfoThenRefresh(bool force) { }, [=](QNetworkReply* reply, const json&) { // zcashd has probably disappeared. 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" + reply->errorString(), QMessageBox::StandardButton::Ok); + shown = false; } prevCallSucceeded = false;