mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
node: update uiInterface whenever warnings updated
This commit introduces slight behaviour change. Previously, the GUI status bar would be updated for most warnings, namely UNKNOWN_NEW_RULES_ACTIVATED, CLOCK_OUT_OF_SYNC and PRE_RELEASE_TEST_BUILD, but not for LARGE_WORK_INVALID_CHAIN (and not for FATAL_INTERNAL_ERROR, but that is not really meaningful). Fix this by always updating the status bar when the warnings are changed.
This commit is contained in:
parent
b071ad9770
commit
9c4b0b7ce4
4 changed files with 10 additions and 9 deletions
|
@ -29,7 +29,6 @@ using util::ReplaceAll;
|
|||
|
||||
static void AlertNotify(const std::string& strMessage)
|
||||
{
|
||||
uiInterface.NotifyAlertChanged();
|
||||
#if HAVE_SYSTEM
|
||||
std::string strCmd = gArgs.GetArg("-alertnotify", "");
|
||||
if (strCmd.empty()) return;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <logging.h>
|
||||
#include <node/interface_ui.h>
|
||||
#include <node/timeoffsets.h>
|
||||
#include <node/warnings.h>
|
||||
#include <sync.h>
|
||||
|
@ -50,7 +49,6 @@ bool TimeOffsets::WarnIfOutOfSync() const
|
|||
auto median{std::max(Median(), std::chrono::seconds(std::numeric_limits<int64_t>::min() + 1))};
|
||||
if (std::chrono::abs(median) <= WARN_THRESHOLD) {
|
||||
node::g_warnings.Unset(node::Warning::CLOCK_OUT_OF_SYNC);
|
||||
uiInterface.NotifyAlertChanged();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -64,6 +62,5 @@ bool TimeOffsets::WarnIfOutOfSync() const
|
|||
), Ticks<std::chrono::minutes>(WARN_THRESHOLD))};
|
||||
LogWarning("%s\n", msg.original);
|
||||
node::g_warnings.Set(node::Warning::CLOCK_OUT_OF_SYNC, msg);
|
||||
uiInterface.NotifyAlertChanged();
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <node/warnings.h>
|
||||
|
||||
#include <common/system.h>
|
||||
#include <node/interface_ui.h>
|
||||
#include <sync.h>
|
||||
#include <univalue.h>
|
||||
#include <util/translation.h>
|
||||
|
@ -31,12 +32,15 @@ bool Warnings::Set(warning_type id, bilingual_str message)
|
|||
{
|
||||
LOCK(m_mutex);
|
||||
const auto& [_, inserted]{m_warnings.insert({id, std::move(message)})};
|
||||
if (inserted) uiInterface.NotifyAlertChanged();
|
||||
return inserted;
|
||||
}
|
||||
|
||||
bool Warnings::Unset(warning_type id)
|
||||
{
|
||||
return WITH_LOCK(m_mutex, return m_warnings.erase(id));
|
||||
auto success{WITH_LOCK(m_mutex, return m_warnings.erase(id))};
|
||||
if (success) uiInterface.NotifyAlertChanged();
|
||||
return success;
|
||||
}
|
||||
|
||||
std::vector<bilingual_str> Warnings::GetMessages() const
|
||||
|
|
|
@ -31,7 +31,7 @@ enum class Warning {
|
|||
* @brief Manages warning messages within a node.
|
||||
*
|
||||
* The Warnings class provides mechanisms to set, unset, and retrieve
|
||||
* warning messages.
|
||||
* warning messages. It updates the GUI when warnings are changed.
|
||||
*
|
||||
* This class is designed to be non-copyable to ensure warnings
|
||||
* are managed centrally.
|
||||
|
@ -52,7 +52,7 @@ public:
|
|||
* @brief Set a warning message. If a warning with the specified
|
||||
* `id` is already active, false is returned and the new
|
||||
* warning is ignored. If `id` does not yet exist, the
|
||||
* warning is set, and true is returned.
|
||||
* warning is set, the UI is updated, and true is returned.
|
||||
*
|
||||
* @param[in] id Unique identifier of the warning.
|
||||
* @param[in] message Warning message to be shown.
|
||||
|
@ -63,8 +63,9 @@ public:
|
|||
bool Set(warning_type id, bilingual_str message) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
|
||||
/**
|
||||
* @brief Unset a warning message. If a warning with the specified
|
||||
* `id` is active, it is unset, and true is returned.
|
||||
* Otherwise, no warning is unset and false is returned.
|
||||
* `id` is active, it is unset, the UI is updated, and true
|
||||
* is returned. Otherwise, no warning is unset and false is
|
||||
* returned.
|
||||
*
|
||||
* @param[in] id Unique identifier of the warning.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue