From 5d66d0a11e84cb447881dcabccb2084bc0686adc Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Fri, 24 Jun 2016 16:35:21 +0200 Subject: [PATCH 1/3] Do not ask a UI question from bitcoind --- src/init.cpp | 3 ++- src/noui.cpp | 6 ++++++ src/qt/bitcoingui.cpp | 2 ++ src/ui_interface.h | 3 +++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index 7a4fe6e60..de42cd376 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1341,8 +1341,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (!fLoaded) { // first suggest a reindex if (!fReset) { - bool fRet = uiInterface.ThreadSafeMessageBox( + bool fRet = uiInterface.ThreadSafeQuestion( strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?"), + strLoadError + ".\nPlease restart with -reindex or -reindex-chainstate to recover.", "", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT); if (fRet) { fReindex = true; diff --git a/src/noui.cpp b/src/noui.cpp index 3a7736191..0d9207c11 100644 --- a/src/noui.cpp +++ b/src/noui.cpp @@ -39,6 +39,11 @@ static bool noui_ThreadSafeMessageBox(const std::string& message, const std::str return false; } +static bool noui_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style) +{ + return noui_ThreadSafeMessageBox(message, caption, style); +} + static void noui_InitMessage(const std::string& message) { LogPrintf("init message: %s\n", message); @@ -48,5 +53,6 @@ void noui_connect() { // Connect bitcoind signal handlers uiInterface.ThreadSafeMessageBox.connect(noui_ThreadSafeMessageBox); + uiInterface.ThreadSafeQuestion.connect(noui_ThreadSafeQuestion); uiInterface.InitMessage.connect(noui_InitMessage); } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index fa5083e00..0dbc15b47 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -1040,12 +1040,14 @@ void BitcoinGUI::subscribeToCoreSignals() { // Connect signals to client uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3)); + uiInterface.ThreadSafeQuestion.connect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4)); } void BitcoinGUI::unsubscribeFromCoreSignals() { // Disconnect signals from client uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3)); + uiInterface.ThreadSafeQuestion.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4)); } UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() : diff --git a/src/ui_interface.h b/src/ui_interface.h index 32a92a4b8..ee0fd9113 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -75,6 +75,9 @@ public: /** Show message box. */ boost::signals2::signal > ThreadSafeMessageBox; + /** If possible, ask the user a question. If not, falls back to ThreadSafeMessageBox(noninteractive_message, caption, style) and returns false. */ + boost::signals2::signal > ThreadSafeQuestion; + /** Progress message during initialization. */ boost::signals2::signal InitMessage; From f42cde3c3022148686cc7176511a4121b055e1b8 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 23 Feb 2017 12:42:28 +0000 Subject: [PATCH 2/3] Remove reference to -reindex-chainstate Revert this when bitcoin/bitcoin#7917 is merged. --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index de42cd376..cff7bfd90 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1343,7 +1343,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (!fReset) { bool fRet = uiInterface.ThreadSafeQuestion( strLoadError + ".\n\n" + _("Do you want to rebuild the block database now?"), - strLoadError + ".\nPlease restart with -reindex or -reindex-chainstate to recover.", + strLoadError + ".\nPlease restart with -reindex to recover.", "", CClientUIInterface::MSG_ERROR | CClientUIInterface::BTN_ABORT); if (fRet) { fReindex = true; From 0cd769fbb7c2af8243a575ce9a889ac91be8d8a4 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 23 Feb 2017 12:55:14 +0000 Subject: [PATCH 3/3] Treat metrics screen as non-interactive for now Closes #2095 --- src/metrics.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/metrics.cpp b/src/metrics.cpp index cbca89671..b63fd16ea 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -101,6 +101,11 @@ static bool metrics_ThreadSafeMessageBox(const std::string& message, return false; } +static bool metrics_ThreadSafeQuestion(const std::string& /* ignored interactive message */, const std::string& message, const std::string& caption, unsigned int style) +{ + return metrics_ThreadSafeMessageBox(message, caption, style); +} + static void metrics_InitMessage(const std::string& message) { *initMessage = message; @@ -110,6 +115,8 @@ void ConnectMetricsScreen() { uiInterface.ThreadSafeMessageBox.disconnect_all_slots(); uiInterface.ThreadSafeMessageBox.connect(metrics_ThreadSafeMessageBox); + uiInterface.ThreadSafeQuestion.disconnect_all_slots(); + uiInterface.ThreadSafeQuestion.connect(metrics_ThreadSafeQuestion); uiInterface.InitMessage.disconnect_all_slots(); uiInterface.InitMessage.connect(metrics_InitMessage); }