mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Merge #18927: Pass bilingual_str argument to AbortNode()
5527be0627
refactor: Add AbortError alias (Hennadii Stepanov)d924f2a596
Drop MSG_NOPREFIX flag (Hennadii Stepanov)083daf7fba
Pass bilingual_str argument to AbortNode() (Hennadii Stepanov)d1cca129b4
refactor: Use bilingual_str::empty() (Hennadii Stepanov) Pull request description: This PR is a [followup](https://github.com/bitcoin/bitcoin/issues/16218#issuecomment-625919724) of #16224, and it adds `bilingual_str` type argument support to the `AbortNode()` functions. ACKs for top commit: MarcoFalke: ACK5527be0627
👟 Tree-SHA512: bf8b15b14912b1f672e6e588fffa1e6eb6f00b4b23d15d0ced7f18fbdf76919244427feb7217007fe29617049308e13def893a03a87358db819cca9692f59905
This commit is contained in:
commit
4b30c41b4e
28
src/noui.cpp
28
src/noui.cpp
@ -23,24 +23,20 @@ bool noui_ThreadSafeMessageBox(const bilingual_str& message, const std::string&
|
||||
{
|
||||
bool fSecure = style & CClientUIInterface::SECURE;
|
||||
style &= ~CClientUIInterface::SECURE;
|
||||
bool prefix = !(style & CClientUIInterface::MSG_NOPREFIX);
|
||||
style &= ~CClientUIInterface::MSG_NOPREFIX;
|
||||
|
||||
std::string strCaption;
|
||||
if (prefix) {
|
||||
switch (style) {
|
||||
case CClientUIInterface::MSG_ERROR:
|
||||
strCaption = "Error: ";
|
||||
break;
|
||||
case CClientUIInterface::MSG_WARNING:
|
||||
strCaption = "Warning: ";
|
||||
break;
|
||||
case CClientUIInterface::MSG_INFORMATION:
|
||||
strCaption = "Information: ";
|
||||
break;
|
||||
default:
|
||||
strCaption = caption + ": "; // Use supplied caption (can be empty)
|
||||
}
|
||||
switch (style) {
|
||||
case CClientUIInterface::MSG_ERROR:
|
||||
strCaption = "Error: ";
|
||||
break;
|
||||
case CClientUIInterface::MSG_WARNING:
|
||||
strCaption = "Warning: ";
|
||||
break;
|
||||
case CClientUIInterface::MSG_INFORMATION:
|
||||
strCaption = "Information: ";
|
||||
break;
|
||||
default:
|
||||
strCaption = caption + ": "; // Use supplied caption (can be empty)
|
||||
}
|
||||
|
||||
if (!fSecure) {
|
||||
|
@ -1069,9 +1069,6 @@ void BitcoinGUI::message(const QString& title, QString message, unsigned int sty
|
||||
int nMBoxIcon = QMessageBox::Information;
|
||||
int nNotifyIcon = Notificator::Information;
|
||||
|
||||
bool prefix = !(style & CClientUIInterface::MSG_NOPREFIX);
|
||||
style &= ~CClientUIInterface::MSG_NOPREFIX;
|
||||
|
||||
QString msgType;
|
||||
if (!title.isEmpty()) {
|
||||
msgType = title;
|
||||
@ -1079,11 +1076,11 @@ void BitcoinGUI::message(const QString& title, QString message, unsigned int sty
|
||||
switch (style) {
|
||||
case CClientUIInterface::MSG_ERROR:
|
||||
msgType = tr("Error");
|
||||
if (prefix) message = tr("Error: %1").arg(message);
|
||||
message = tr("Error: %1").arg(message);
|
||||
break;
|
||||
case CClientUIInterface::MSG_WARNING:
|
||||
msgType = tr("Warning");
|
||||
if (prefix) message = tr("Warning: %1").arg(message);
|
||||
message = tr("Warning: %1").arg(message);
|
||||
break;
|
||||
case CClientUIInterface::MSG_INFORMATION:
|
||||
msgType = tr("Information");
|
||||
|
@ -262,7 +262,7 @@ void CreateWalletActivity::finish()
|
||||
{
|
||||
destroyProgressDialog();
|
||||
|
||||
if (!m_error_message.original.empty()) {
|
||||
if (!m_error_message.empty()) {
|
||||
QMessageBox::critical(m_parent_widget, tr("Create wallet failed"), QString::fromStdString(m_error_message.translated));
|
||||
} else if (!m_warning_message.empty()) {
|
||||
QMessageBox::warning(m_parent_widget, tr("Create wallet warning"), QString::fromStdString(Join(m_warning_message, Untranslated("\n")).translated));
|
||||
@ -303,7 +303,7 @@ void OpenWalletActivity::finish()
|
||||
{
|
||||
destroyProgressDialog();
|
||||
|
||||
if (!m_error_message.original.empty()) {
|
||||
if (!m_error_message.empty()) {
|
||||
QMessageBox::critical(m_parent_widget, tr("Open wallet failed"), QString::fromStdString(m_error_message.translated));
|
||||
} else if (!m_warning_message.empty()) {
|
||||
QMessageBox::warning(m_parent_widget, tr("Open wallet warning"), QString::fromStdString(Join(m_warning_message, Untranslated("\n")).translated));
|
||||
|
@ -67,9 +67,6 @@ public:
|
||||
/** Force blocking, modal message box dialog (not just OS notification) */
|
||||
MODAL = 0x10000000U,
|
||||
|
||||
/** Do not prepend error/warning prefix */
|
||||
MSG_NOPREFIX = 0x20000000U,
|
||||
|
||||
/** Do not print contents of message to debug log */
|
||||
SECURE = 0x40000000U,
|
||||
|
||||
|
@ -1662,24 +1662,24 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
|
||||
return true;
|
||||
}
|
||||
|
||||
constexpr auto AbortError = InitError;
|
||||
|
||||
/** Abort with a message */
|
||||
// TODO: AbortNode() should take bilingual_str userMessage parameter.
|
||||
static bool AbortNode(const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
|
||||
static bool AbortNode(const std::string& strMessage, bilingual_str user_message = bilingual_str())
|
||||
{
|
||||
SetMiscWarning(Untranslated(strMessage));
|
||||
LogPrintf("*** %s\n", strMessage);
|
||||
if (!userMessage.empty()) {
|
||||
uiInterface.ThreadSafeMessageBox(Untranslated(userMessage), "", CClientUIInterface::MSG_ERROR | prefix);
|
||||
} else {
|
||||
uiInterface.ThreadSafeMessageBox(_("Error: A fatal internal error occurred, see debug.log for details"), "", CClientUIInterface::MSG_ERROR | CClientUIInterface::MSG_NOPREFIX);
|
||||
if (user_message.empty()) {
|
||||
user_message = _("A fatal internal error occurred, see debug.log for details");
|
||||
}
|
||||
AbortError(user_message);
|
||||
StartShutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool AbortNode(BlockValidationState& state, const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
|
||||
static bool AbortNode(BlockValidationState& state, const std::string& strMessage, const bilingual_str& userMessage = bilingual_str())
|
||||
{
|
||||
AbortNode(strMessage, userMessage, prefix);
|
||||
AbortNode(strMessage, userMessage);
|
||||
return state.Error(strMessage);
|
||||
}
|
||||
|
||||
@ -2344,7 +2344,7 @@ bool CChainState::FlushStateToDisk(
|
||||
if (fDoFullFlush || fPeriodicWrite) {
|
||||
// Depend on nMinDiskSpace to ensure we can write block index
|
||||
if (!CheckDiskSpace(GetBlocksDir())) {
|
||||
return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!").translated, CClientUIInterface::MSG_NOPREFIX);
|
||||
return AbortNode(state, "Disk space is too low!", _("Disk space is too low!"));
|
||||
}
|
||||
{
|
||||
LOG_TIME_MILLIS_WITH_CATEGORY("write block and undo data to disk", BCLog::BENCH);
|
||||
@ -2392,7 +2392,7 @@ bool CChainState::FlushStateToDisk(
|
||||
// an overestimation, as most will delete an existing entry or
|
||||
// overwrite one. Still, use a conservative safety factor of 2.
|
||||
if (!CheckDiskSpace(GetDataDir(), 48 * 2 * 2 * CoinsTip().GetCacheSize())) {
|
||||
return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!").translated, CClientUIInterface::MSG_NOPREFIX);
|
||||
return AbortNode(state, "Disk space is too low!", _("Disk space is too low!"));
|
||||
}
|
||||
// Flush the chainstate (which may refer to block index entries).
|
||||
if (!CoinsTip().Flush())
|
||||
@ -3299,7 +3299,7 @@ static bool FindBlockPos(FlatFilePos &pos, unsigned int nAddSize, unsigned int n
|
||||
bool out_of_space;
|
||||
size_t bytes_allocated = BlockFileSeq().Allocate(pos, nAddSize, out_of_space);
|
||||
if (out_of_space) {
|
||||
return AbortNode("Disk space is too low!", _("Error: Disk space is too low!").translated, CClientUIInterface::MSG_NOPREFIX);
|
||||
return AbortNode("Disk space is too low!", _("Disk space is too low!"));
|
||||
}
|
||||
if (bytes_allocated != 0 && fPruneMode) {
|
||||
fCheckForPruning = true;
|
||||
@ -3323,7 +3323,7 @@ static bool FindUndoPos(BlockValidationState &state, int nFile, FlatFilePos &pos
|
||||
bool out_of_space;
|
||||
size_t bytes_allocated = UndoFileSeq().Allocate(pos, nAddSize, out_of_space);
|
||||
if (out_of_space) {
|
||||
return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!").translated, CClientUIInterface::MSG_NOPREFIX);
|
||||
return AbortNode(state, "Disk space is too low!", _("Disk space is too low!"));
|
||||
}
|
||||
if (bytes_allocated != 0 && fPruneMode) {
|
||||
fCheckForPruning = true;
|
||||
|
Loading…
Reference in New Issue
Block a user