Drop MSG_NOPREFIX flag

Since bilingual_str type is fully supported, the MSG_NOPREFIX flag is no
longer needed.
This commit is contained in:
Hennadii Stepanov 2020-05-10 12:43:30 +03:00
parent 083daf7fba
commit d924f2a596
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
4 changed files with 23 additions and 33 deletions

View file

@ -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) {

View file

@ -1062,9 +1062,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;
@ -1072,11 +1069,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");

View file

@ -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,

View file

@ -1655,22 +1655,22 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
}
/** Abort with a message */
static bool AbortNode(const std::string& strMessage, const bilingual_str& userMessage = bilingual_str(), unsigned int prefix = 0)
static bool AbortNode(const std::string& strMessage, const bilingual_str& userMessage = bilingual_str())
{
SetMiscWarning(strMessage);
LogPrintf("*** %s\n", strMessage);
if (!userMessage.empty()) {
uiInterface.ThreadSafeMessageBox(userMessage, "", CClientUIInterface::MSG_ERROR | prefix);
uiInterface.ThreadSafeMessageBox(userMessage, "", CClientUIInterface::MSG_ERROR);
} else {
uiInterface.ThreadSafeMessageBox(_("Error: A fatal internal error occurred, see debug.log for details"), "", CClientUIInterface::MSG_ERROR | CClientUIInterface::MSG_NOPREFIX);
uiInterface.ThreadSafeMessageBox(_("A fatal internal error occurred, see debug.log for details"), "", CClientUIInterface::MSG_ERROR);
}
StartShutdown();
return false;
}
static bool AbortNode(BlockValidationState& state, const std::string& strMessage, const bilingual_str& userMessage = bilingual_str(), 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);
}
@ -2335,7 +2335,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!"), 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);
@ -2383,7 +2383,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!"), 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())
@ -3290,7 +3290,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!"), CClientUIInterface::MSG_NOPREFIX);
return AbortNode("Disk space is too low!", _("Disk space is too low!"));
}
if (bytes_allocated != 0 && fPruneMode) {
fCheckForPruning = true;
@ -3314,7 +3314,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!"), CClientUIInterface::MSG_NOPREFIX);
return AbortNode(state, "Disk space is too low!", _("Disk space is too low!"));
}
if (bytes_allocated != 0 && fPruneMode) {
fCheckForPruning = true;