diff options
author | stickies-v <stickies-v@protonmail.com> | 2024-05-07 17:22:49 +0100 |
---|---|---|
committer | stickies-v <stickies-v@protonmail.com> | 2024-06-13 11:20:48 +0100 |
commit | 9c4b0b7ce459765fa1a63b410c3423b90f0d2a5f (patch) | |
tree | 7cdc71d2927bb330706337e12264d4131c804b60 /src/node | |
parent | b071ad9770b7ae7fc718dcbfdc8f62dffbf6cfee (diff) | |
download | bitcoin-9c4b0b7ce459765fa1a63b410c3423b90f0d2a5f.tar.xz |
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.
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/kernel_notifications.cpp | 1 | ||||
-rw-r--r-- | src/node/timeoffsets.cpp | 3 | ||||
-rw-r--r-- | src/node/warnings.cpp | 6 | ||||
-rw-r--r-- | src/node/warnings.h | 9 |
4 files changed, 10 insertions, 9 deletions
diff --git a/src/node/kernel_notifications.cpp b/src/node/kernel_notifications.cpp index e18919f503..c1a9e351b9 100644 --- a/src/node/kernel_notifications.cpp +++ b/src/node/kernel_notifications.cpp @@ -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; diff --git a/src/node/timeoffsets.cpp b/src/node/timeoffsets.cpp index b839b60565..d06a07b15a 100644 --- a/src/node/timeoffsets.cpp +++ b/src/node/timeoffsets.cpp @@ -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; } diff --git a/src/node/warnings.cpp b/src/node/warnings.cpp index 8a94eb0bd2..4e7fd3941c 100644 --- a/src/node/warnings.cpp +++ b/src/node/warnings.cpp @@ -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 diff --git a/src/node/warnings.h b/src/node/warnings.h index c85e8a16a9..b7ff74ecf4 100644 --- a/src/node/warnings.h +++ b/src/node/warnings.h @@ -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. * |