mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02: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
@ -29,7 +29,6 @@ using util::ReplaceAll;
|
|||||||
|
|
||||||
static void AlertNotify(const std::string& strMessage)
|
static void AlertNotify(const std::string& strMessage)
|
||||||
{
|
{
|
||||||
uiInterface.NotifyAlertChanged();
|
|
||||||
#if HAVE_SYSTEM
|
#if HAVE_SYSTEM
|
||||||
std::string strCmd = gArgs.GetArg("-alertnotify", "");
|
std::string strCmd = gArgs.GetArg("-alertnotify", "");
|
||||||
if (strCmd.empty()) return;
|
if (strCmd.empty()) return;
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
#include <logging.h>
|
#include <logging.h>
|
||||||
#include <node/interface_ui.h>
|
|
||||||
#include <node/timeoffsets.h>
|
#include <node/timeoffsets.h>
|
||||||
#include <node/warnings.h>
|
#include <node/warnings.h>
|
||||||
#include <sync.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))};
|
auto median{std::max(Median(), std::chrono::seconds(std::numeric_limits<int64_t>::min() + 1))};
|
||||||
if (std::chrono::abs(median) <= WARN_THRESHOLD) {
|
if (std::chrono::abs(median) <= WARN_THRESHOLD) {
|
||||||
node::g_warnings.Unset(node::Warning::CLOCK_OUT_OF_SYNC);
|
node::g_warnings.Unset(node::Warning::CLOCK_OUT_OF_SYNC);
|
||||||
uiInterface.NotifyAlertChanged();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,6 +62,5 @@ bool TimeOffsets::WarnIfOutOfSync() const
|
|||||||
), Ticks<std::chrono::minutes>(WARN_THRESHOLD))};
|
), Ticks<std::chrono::minutes>(WARN_THRESHOLD))};
|
||||||
LogWarning("%s\n", msg.original);
|
LogWarning("%s\n", msg.original);
|
||||||
node::g_warnings.Set(node::Warning::CLOCK_OUT_OF_SYNC, msg);
|
node::g_warnings.Set(node::Warning::CLOCK_OUT_OF_SYNC, msg);
|
||||||
uiInterface.NotifyAlertChanged();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include <node/warnings.h>
|
#include <node/warnings.h>
|
||||||
|
|
||||||
#include <common/system.h>
|
#include <common/system.h>
|
||||||
|
#include <node/interface_ui.h>
|
||||||
#include <sync.h>
|
#include <sync.h>
|
||||||
#include <univalue.h>
|
#include <univalue.h>
|
||||||
#include <util/translation.h>
|
#include <util/translation.h>
|
||||||
@ -31,12 +32,15 @@ bool Warnings::Set(warning_type id, bilingual_str message)
|
|||||||
{
|
{
|
||||||
LOCK(m_mutex);
|
LOCK(m_mutex);
|
||||||
const auto& [_, inserted]{m_warnings.insert({id, std::move(message)})};
|
const auto& [_, inserted]{m_warnings.insert({id, std::move(message)})};
|
||||||
|
if (inserted) uiInterface.NotifyAlertChanged();
|
||||||
return inserted;
|
return inserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Warnings::Unset(warning_type id)
|
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
|
std::vector<bilingual_str> Warnings::GetMessages() const
|
||||||
|
@ -31,7 +31,7 @@ enum class Warning {
|
|||||||
* @brief Manages warning messages within a node.
|
* @brief Manages warning messages within a node.
|
||||||
*
|
*
|
||||||
* The Warnings class provides mechanisms to set, unset, and retrieve
|
* 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
|
* This class is designed to be non-copyable to ensure warnings
|
||||||
* are managed centrally.
|
* are managed centrally.
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
* @brief Set a warning message. If a warning with the specified
|
* @brief Set a warning message. If a warning with the specified
|
||||||
* `id` is already active, false is returned and the new
|
* `id` is already active, false is returned and the new
|
||||||
* warning is ignored. If `id` does not yet exist, the
|
* 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] id Unique identifier of the warning.
|
||||||
* @param[in] message Warning message to be shown.
|
* @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);
|
bool Set(warning_type id, bilingual_str message) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
|
||||||
/**
|
/**
|
||||||
* @brief Unset a warning message. If a warning with the specified
|
* @brief Unset a warning message. If a warning with the specified
|
||||||
* `id` is active, it is unset, and true is returned.
|
* `id` is active, it is unset, the UI is updated, and true
|
||||||
* Otherwise, no warning is unset and false is returned.
|
* is returned. Otherwise, no warning is unset and false is
|
||||||
|
* returned.
|
||||||
*
|
*
|
||||||
* @param[in] id Unique identifier of the warning.
|
* @param[in] id Unique identifier of the warning.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user