Skip to content

Commit 9c4b0b7

Browse files
committed
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.
1 parent b071ad9 commit 9c4b0b7

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/node/kernel_notifications.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ using util::ReplaceAll;
2929

3030
static void AlertNotify(const std::string& strMessage)
3131
{
32-
uiInterface.NotifyAlertChanged();
3332
#if HAVE_SYSTEM
3433
std::string strCmd = gArgs.GetArg("-alertnotify", "");
3534
if (strCmd.empty()) return;

src/node/timeoffsets.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <logging.h>
6-
#include <node/interface_ui.h>
76
#include <node/timeoffsets.h>
87
#include <node/warnings.h>
98
#include <sync.h>
@@ -50,7 +49,6 @@ bool TimeOffsets::WarnIfOutOfSync() const
5049
auto median{std::max(Median(), std::chrono::seconds(std::numeric_limits<int64_t>::min() + 1))};
5150
if (std::chrono::abs(median) <= WARN_THRESHOLD) {
5251
node::g_warnings.Unset(node::Warning::CLOCK_OUT_OF_SYNC);
53-
uiInterface.NotifyAlertChanged();
5452
return false;
5553
}
5654

@@ -64,6 +62,5 @@ bool TimeOffsets::WarnIfOutOfSync() const
6462
), Ticks<std::chrono::minutes>(WARN_THRESHOLD))};
6563
LogWarning("%s\n", msg.original);
6664
node::g_warnings.Set(node::Warning::CLOCK_OUT_OF_SYNC, msg);
67-
uiInterface.NotifyAlertChanged();
6865
return true;
6966
}

src/node/warnings.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <node/warnings.h>
99

1010
#include <common/system.h>
11+
#include <node/interface_ui.h>
1112
#include <sync.h>
1213
#include <univalue.h>
1314
#include <util/translation.h>
@@ -31,12 +32,15 @@ bool Warnings::Set(warning_type id, bilingual_str message)
3132
{
3233
LOCK(m_mutex);
3334
const auto& [_, inserted]{m_warnings.insert({id, std::move(message)})};
35+
if (inserted) uiInterface.NotifyAlertChanged();
3436
return inserted;
3537
}
3638

3739
bool Warnings::Unset(warning_type id)
3840
{
39-
return WITH_LOCK(m_mutex, return m_warnings.erase(id));
41+
auto success{WITH_LOCK(m_mutex, return m_warnings.erase(id))};
42+
if (success) uiInterface.NotifyAlertChanged();
43+
return success;
4044
}
4145

4246
std::vector<bilingual_str> Warnings::GetMessages() const

src/node/warnings.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum class Warning {
3131
* @brief Manages warning messages within a node.
3232
*
3333
* The Warnings class provides mechanisms to set, unset, and retrieve
34-
* warning messages.
34+
* warning messages. It updates the GUI when warnings are changed.
3535
*
3636
* This class is designed to be non-copyable to ensure warnings
3737
* are managed centrally.
@@ -52,7 +52,7 @@ class Warnings
5252
* @brief Set a warning message. If a warning with the specified
5353
* `id` is already active, false is returned and the new
5454
* warning is ignored. If `id` does not yet exist, the
55-
* warning is set, and true is returned.
55+
* warning is set, the UI is updated, and true is returned.
5656
*
5757
* @param[in] id Unique identifier of the warning.
5858
* @param[in] message Warning message to be shown.
@@ -63,8 +63,9 @@ class Warnings
6363
bool Set(warning_type id, bilingual_str message) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
6464
/**
6565
* @brief Unset a warning message. If a warning with the specified
66-
* `id` is active, it is unset, and true is returned.
67-
* Otherwise, no warning is unset and false is returned.
66+
* `id` is active, it is unset, the UI is updated, and true
67+
* is returned. Otherwise, no warning is unset and false is
68+
* returned.
6869
*
6970
* @param[in] id Unique identifier of the warning.
7071
*

0 commit comments

Comments
 (0)