Skip to content

Commit d49612f

Browse files
committed
Make SetMiscWarning() accept bilingual_str argument
1 parent d1ae7c0 commit d49612f

File tree

5 files changed

+20
-20
lines changed

5 files changed

+20
-20
lines changed

src/index/base.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ template<typename... Args>
2121
static void FatalError(const char* fmt, const Args&... args)
2222
{
2323
std::string strMessage = tfm::format(fmt, args...);
24-
SetMiscWarning(strMessage);
24+
SetMiscWarning(Untranslated(strMessage));
2525
LogPrintf("*** %s\n", strMessage);
2626
uiInterface.ThreadSafeMessageBox(
2727
Untranslated("Error: A fatal internal error occurred, see debug.log for details"),

src/timedata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample)
9595
if (!fMatch) {
9696
fDone = true;
9797
bilingual_str strMessage = strprintf(_("Please check that your computer's date and time are correct! If your clock is wrong, %s will not work properly."), PACKAGE_NAME);
98-
SetMiscWarning(strMessage.translated);
98+
SetMiscWarning(strMessage);
9999
uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING);
100100
}
101101
}

src/validation.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,7 +1666,7 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
16661666
// TODO: AbortNode() should take bilingual_str userMessage parameter.
16671667
static bool AbortNode(const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
16681668
{
1669-
SetMiscWarning(strMessage);
1669+
SetMiscWarning(Untranslated(strMessage));
16701670
LogPrintf("*** %s\n", strMessage);
16711671
if (!userMessage.empty()) {
16721672
uiInterface.ThreadSafeMessageBox(Untranslated(userMessage), "", CClientUIInterface::MSG_ERROR | prefix);
@@ -2429,20 +2429,20 @@ void CChainState::PruneAndFlush() {
24292429
}
24302430
}
24312431

2432-
static void DoWarning(const std::string& strWarning)
2432+
static void DoWarning(const bilingual_str& warning)
24332433
{
24342434
static bool fWarned = false;
2435-
SetMiscWarning(strWarning);
2435+
SetMiscWarning(warning);
24362436
if (!fWarned) {
2437-
AlertNotify(strWarning);
2437+
AlertNotify(warning.original);
24382438
fWarned = true;
24392439
}
24402440
}
24412441

24422442
/** Private helper function that concatenates warning messages. */
2443-
static void AppendWarning(std::string& res, const std::string& warn)
2443+
static void AppendWarning(bilingual_str& res, const bilingual_str& warn)
24442444
{
2445-
if (!res.empty()) res += ", ";
2445+
if (!res.empty()) res += Untranslated(", ");
24462446
res += warn;
24472447
}
24482448

@@ -2459,7 +2459,7 @@ void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainPar
24592459
g_best_block_cv.notify_all();
24602460
}
24612461

2462-
std::string warningMessages;
2462+
bilingual_str warning_messages;
24632463
if (!::ChainstateActive().IsInitialBlockDownload())
24642464
{
24652465
int nUpgraded = 0;
@@ -2468,11 +2468,11 @@ void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainPar
24682468
WarningBitsConditionChecker checker(bit);
24692469
ThresholdState state = checker.GetStateFor(pindex, chainParams.GetConsensus(), warningcache[bit]);
24702470
if (state == ThresholdState::ACTIVE || state == ThresholdState::LOCKED_IN) {
2471-
const std::string strWarning = strprintf(_("Warning: unknown new rules activated (versionbit %i)").translated, bit);
2471+
const bilingual_str warning = strprintf(_("Warning: unknown new rules activated (versionbit %i)"), bit);
24722472
if (state == ThresholdState::ACTIVE) {
2473-
DoWarning(strWarning);
2473+
DoWarning(warning);
24742474
} else {
2475-
AppendWarning(warningMessages, strWarning);
2475+
AppendWarning(warning_messages, warning);
24762476
}
24772477
}
24782478
}
@@ -2485,14 +2485,14 @@ void static UpdateTip(const CBlockIndex* pindexNew, const CChainParams& chainPar
24852485
pindex = pindex->pprev;
24862486
}
24872487
if (nUpgraded > 0)
2488-
AppendWarning(warningMessages, strprintf(_("%d of last 100 blocks have unexpected version").translated, nUpgraded));
2488+
AppendWarning(warning_messages, strprintf(_("%d of last 100 blocks have unexpected version"), nUpgraded));
24892489
}
24902490
LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)%s\n", __func__,
24912491
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, pindexNew->nVersion,
24922492
log(pindexNew->nChainWork.getdouble())/log(2.0), (unsigned long)pindexNew->nChainTx,
24932493
FormatISO8601DateTime(pindexNew->GetBlockTime()),
24942494
GuessVerificationProgress(chainParams.TxData(), pindexNew), ::ChainstateActive().CoinsTip().DynamicMemoryUsage() * (1.0 / (1<<20)), ::ChainstateActive().CoinsTip().GetCacheSize(),
2495-
!warningMessages.empty() ? strprintf(" warning='%s'", warningMessages) : "");
2495+
!warning_messages.empty() ? strprintf(" warning='%s'", warning_messages.original) : "");
24962496

24972497
}
24982498

src/warnings.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
#include <vector>
1414

1515
static Mutex g_warnings_mutex;
16-
static std::string strMiscWarning GUARDED_BY(g_warnings_mutex);
16+
static bilingual_str g_misc_warnings GUARDED_BY(g_warnings_mutex);
1717
static bool fLargeWorkForkFound GUARDED_BY(g_warnings_mutex) = false;
1818
static bool fLargeWorkInvalidChainFound GUARDED_BY(g_warnings_mutex) = false;
1919

20-
void SetMiscWarning(const std::string& strWarning)
20+
void SetMiscWarning(const bilingual_str& warning)
2121
{
2222
LOCK(g_warnings_mutex);
23-
strMiscWarning = strWarning;
23+
g_misc_warnings = warning;
2424
}
2525

2626
void SetfLargeWorkForkFound(bool flag)
@@ -55,8 +55,8 @@ bilingual_str GetWarnings(bool verbose)
5555
}
5656

5757
// Misc warnings like out of disk space and clock is wrong
58-
if (!strMiscWarning.empty()) {
59-
warnings_concise = Untranslated(strMiscWarning);
58+
if (!g_misc_warnings.empty()) {
59+
warnings_concise = g_misc_warnings;
6060
warnings_verbose.emplace_back(warnings_concise);
6161
}
6262

src/warnings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
struct bilingual_str;
1212

13-
void SetMiscWarning(const std::string& strWarning);
13+
void SetMiscWarning(const bilingual_str& warning);
1414
void SetfLargeWorkForkFound(bool flag);
1515
bool GetfLargeWorkForkFound();
1616
void SetfLargeWorkInvalidChainFound(bool flag);

0 commit comments

Comments
 (0)