mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
Merge #15894: Remove duplicated "Error: " prefix in logs
f724f31401b963c75bd64f5e2c5b9d9561a9a9dd Make AbortNode() aware of MSG_NOPREFIX flag (Hennadii Stepanov) 96fd4ee02f6c3be21cade729b95a85c60634b0f8 Add MSG_NOPREFIX flag for user messages (Hennadii Stepanov) f0641f274ffe94fbe7cae43c07a9373013739df2 Prepend the error/warning prefix for GUI messages (Hennadii Stepanov) Pull request description: The "Error" prefix/title is set already in the next functions: - `noui_ThreadSafeMessageBox()`2068f089c8/src/noui.cpp (L17)
- `ThreadSafeMessageBox()`a720a98301/src/qt/bitcoingui.cpp (L1351)
Currently on master: ![Screenshot from 2019-04-25 22-08-54](https://user-images.githubusercontent.com/32963518/56763092-25ee8280-67aa-11e9-86c8-6a029dd9ab08.png) With this PR: ![Screenshot from 2019-04-25 22-26-36](https://user-images.githubusercontent.com/32963518/56763107-30108100-67aa-11e9-9021-683cbd7e2aaa.png) ACKs for top commit: laanwj: concept and code-review ACK f724f31401b963c75bd64f5e2c5b9d9561a9a9dd Tree-SHA512: 218a179b81cc2ac64239d833c02b4c4d4da9b976728a2dcd645966726c4c660b6f1fe43aa28f33d1cb566785a4329e7f93bf5a502bf202316db79d2ff5fce0f8
This commit is contained in:
parent
6d6630d251
commit
93f168eee3
36
src/noui.cpp
36
src/noui.cpp
@ -25,26 +25,30 @@ bool noui_ThreadSafeMessageBox(const std::string& message, const std::string& ca
|
|||||||
{
|
{
|
||||||
bool fSecure = style & CClientUIInterface::SECURE;
|
bool fSecure = style & CClientUIInterface::SECURE;
|
||||||
style &= ~CClientUIInterface::SECURE;
|
style &= ~CClientUIInterface::SECURE;
|
||||||
|
bool prefix = !(style & CClientUIInterface::MSG_NOPREFIX);
|
||||||
|
style &= ~CClientUIInterface::MSG_NOPREFIX;
|
||||||
|
|
||||||
std::string strCaption;
|
std::string strCaption;
|
||||||
// Check for usage of predefined caption
|
if (prefix) {
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case CClientUIInterface::MSG_ERROR:
|
case CClientUIInterface::MSG_ERROR:
|
||||||
strCaption += _("Error");
|
strCaption = "Error: ";
|
||||||
break;
|
break;
|
||||||
case CClientUIInterface::MSG_WARNING:
|
case CClientUIInterface::MSG_WARNING:
|
||||||
strCaption += _("Warning");
|
strCaption = "Warning: ";
|
||||||
break;
|
break;
|
||||||
case CClientUIInterface::MSG_INFORMATION:
|
case CClientUIInterface::MSG_INFORMATION:
|
||||||
strCaption += _("Information");
|
strCaption = "Information: ";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
strCaption += caption; // Use supplied caption (can be empty)
|
strCaption = caption + ": "; // Use supplied caption (can be empty)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fSecure)
|
if (!fSecure) {
|
||||||
LogPrintf("%s: %s\n", strCaption, message);
|
LogPrintf("%s%s\n", strCaption, message);
|
||||||
tfm::format(std::cerr, "%s: %s\n", strCaption.c_str(), message.c_str());
|
}
|
||||||
|
tfm::format(std::cerr, "%s%s\n", strCaption.c_str(), message.c_str());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1504,49 +1504,51 @@ void BitcoinGUI::setAdditionalDataSyncProgress(double nSyncProgress)
|
|||||||
progressBar->setToolTip(tooltip);
|
progressBar->setToolTip(tooltip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
|
void BitcoinGUI::message(const QString& title, QString message, unsigned int style, bool* ret)
|
||||||
{
|
{
|
||||||
QString strTitle = tr("Dash Core"); // default title
|
// Default title. On macOS, the window title is ignored (as required by the macOS Guidelines).
|
||||||
|
QString strTitle{PACKAGE_NAME};
|
||||||
// Default to information icon
|
// Default to information icon
|
||||||
int nMBoxIcon = QMessageBox::Information;
|
int nMBoxIcon = QMessageBox::Information;
|
||||||
int nNotifyIcon = Notificator::Information;
|
int nNotifyIcon = Notificator::Information;
|
||||||
|
|
||||||
QString msgType;
|
bool prefix = !(style & CClientUIInterface::MSG_NOPREFIX);
|
||||||
|
style &= ~CClientUIInterface::MSG_NOPREFIX;
|
||||||
|
|
||||||
// Prefer supplied title over style based title
|
QString msgType;
|
||||||
if (!title.isEmpty()) {
|
if (!title.isEmpty()) {
|
||||||
msgType = title;
|
msgType = title;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case CClientUIInterface::MSG_ERROR:
|
case CClientUIInterface::MSG_ERROR:
|
||||||
msgType = tr("Error");
|
msgType = tr("Error");
|
||||||
|
if (prefix) message = tr("Error: %1").arg(message);
|
||||||
break;
|
break;
|
||||||
case CClientUIInterface::MSG_WARNING:
|
case CClientUIInterface::MSG_WARNING:
|
||||||
msgType = tr("Warning");
|
msgType = tr("Warning");
|
||||||
|
if (prefix) message = tr("Warning: %1").arg(message);
|
||||||
break;
|
break;
|
||||||
case CClientUIInterface::MSG_INFORMATION:
|
case CClientUIInterface::MSG_INFORMATION:
|
||||||
msgType = tr("Information");
|
msgType = tr("Information");
|
||||||
|
// No need to prepend the prefix here.
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Append title to "Dash Core - "
|
|
||||||
if (!msgType.isEmpty())
|
|
||||||
strTitle += " - " + msgType;
|
|
||||||
|
|
||||||
// Check for error/warning icon
|
if (!msgType.isEmpty()) {
|
||||||
|
strTitle += " - " + msgType;
|
||||||
|
}
|
||||||
|
|
||||||
if (style & CClientUIInterface::ICON_ERROR) {
|
if (style & CClientUIInterface::ICON_ERROR) {
|
||||||
nMBoxIcon = QMessageBox::Critical;
|
nMBoxIcon = QMessageBox::Critical;
|
||||||
nNotifyIcon = Notificator::Critical;
|
nNotifyIcon = Notificator::Critical;
|
||||||
}
|
} else if (style & CClientUIInterface::ICON_WARNING) {
|
||||||
else if (style & CClientUIInterface::ICON_WARNING) {
|
|
||||||
nMBoxIcon = QMessageBox::Warning;
|
nMBoxIcon = QMessageBox::Warning;
|
||||||
nNotifyIcon = Notificator::Warning;
|
nNotifyIcon = Notificator::Warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display message
|
|
||||||
if (style & CClientUIInterface::MODAL) {
|
if (style & CClientUIInterface::MODAL) {
|
||||||
// Check for buttons, use OK as default, if none was supplied
|
// Check for buttons, use OK as default, if none was supplied
|
||||||
QMessageBox::StandardButton buttons;
|
QMessageBox::StandardButton buttons;
|
||||||
@ -1559,9 +1561,9 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
|
|||||||
int r = mBox.exec();
|
int r = mBox.exec();
|
||||||
if (ret != nullptr)
|
if (ret != nullptr)
|
||||||
*ret = r == QMessageBox::Ok;
|
*ret = r == QMessageBox::Ok;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
notificator->notify(static_cast<Notificator::Class>(nNotifyIcon), strTitle, message);
|
notificator->notify(static_cast<Notificator::Class>(nNotifyIcon), strTitle, message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::changeEvent(QEvent *e)
|
void BitcoinGUI::changeEvent(QEvent *e)
|
||||||
|
@ -262,7 +262,7 @@ public Q_SLOTS:
|
|||||||
@see CClientUIInterface::MessageBoxFlags
|
@see CClientUIInterface::MessageBoxFlags
|
||||||
@param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only)
|
@param[in] ret pointer to a bool that will be modified to whether Ok was clicked (modal only)
|
||||||
*/
|
*/
|
||||||
void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
|
void message(const QString& title, QString message, unsigned int style, bool* ret = nullptr);
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
void setCurrentWallet(WalletModel* wallet_model);
|
void setCurrentWallet(WalletModel* wallet_model);
|
||||||
|
@ -70,6 +70,9 @@ public:
|
|||||||
/** Force blocking, modal message box dialog (not just OS notification) */
|
/** Force blocking, modal message box dialog (not just OS notification) */
|
||||||
MODAL = 0x10000000U,
|
MODAL = 0x10000000U,
|
||||||
|
|
||||||
|
/** Do not prepend error/warning prefix */
|
||||||
|
MSG_NOPREFIX = 0x20000000U,
|
||||||
|
|
||||||
/** Do not print contents of message to debug log */
|
/** Do not print contents of message to debug log */
|
||||||
SECURE = 0x40000000U,
|
SECURE = 0x40000000U,
|
||||||
|
|
||||||
|
@ -1549,20 +1549,22 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Abort with a message */
|
/** Abort with a message */
|
||||||
static bool AbortNode(const std::string& strMessage, const std::string& userMessage="")
|
static bool AbortNode(const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
|
||||||
{
|
{
|
||||||
SetMiscWarning(strMessage);
|
SetMiscWarning(strMessage);
|
||||||
LogPrintf("*** %s\n", strMessage);
|
LogPrintf("*** %s\n", strMessage);
|
||||||
uiInterface.ThreadSafeMessageBox(
|
if (!userMessage.empty()) {
|
||||||
userMessage.empty() ? _("Error: A fatal internal error occurred, see debug.log for details") : userMessage,
|
uiInterface.ThreadSafeMessageBox(userMessage, "", CClientUIInterface::MSG_ERROR | prefix);
|
||||||
"", CClientUIInterface::MSG_ERROR);
|
} else {
|
||||||
|
uiInterface.ThreadSafeMessageBox(_("Error: A fatal internal error occurred, see debug.log for details"), "", CClientUIInterface::MSG_ERROR | CClientUIInterface::MSG_NOPREFIX);
|
||||||
|
}
|
||||||
StartShutdown();
|
StartShutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage="")
|
static bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
|
||||||
{
|
{
|
||||||
AbortNode(strMessage, userMessage);
|
AbortNode(strMessage, userMessage, prefix);
|
||||||
return state.Error(strMessage);
|
return state.Error(strMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2485,7 +2487,7 @@ bool CChainState::FlushStateToDisk(
|
|||||||
if (fDoFullFlush || fPeriodicWrite) {
|
if (fDoFullFlush || fPeriodicWrite) {
|
||||||
// Depend on nMinDiskSpace to ensure we can write block index
|
// Depend on nMinDiskSpace to ensure we can write block index
|
||||||
if (!CheckDiskSpace(GetBlocksDir())) {
|
if (!CheckDiskSpace(GetBlocksDir())) {
|
||||||
return AbortNode(state, "Disk space is low!", _("Error: Disk space is low!"));
|
return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!"), CClientUIInterface::MSG_NOPREFIX);
|
||||||
}
|
}
|
||||||
// First make sure all block and undo data is flushed to disk.
|
// First make sure all block and undo data is flushed to disk.
|
||||||
{
|
{
|
||||||
@ -2534,7 +2536,7 @@ bool CChainState::FlushStateToDisk(
|
|||||||
// an overestimation, as most will delete an existing entry or
|
// an overestimation, as most will delete an existing entry or
|
||||||
// overwrite one. Still, use a conservative safety factor of 2.
|
// overwrite one. Still, use a conservative safety factor of 2.
|
||||||
if (!CheckDiskSpace(GetDataDir(), 48 * 2 * 2 * CoinsTip().GetCacheSize())) {
|
if (!CheckDiskSpace(GetDataDir(), 48 * 2 * 2 * CoinsTip().GetCacheSize())) {
|
||||||
return AbortNode(state, "Disk space is low!", _("Error: Disk space is low!"));
|
return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!"), CClientUIInterface::MSG_NOPREFIX);
|
||||||
}
|
}
|
||||||
// Flush the chainstate (which may refer to block index entries).
|
// Flush the chainstate (which may refer to block index entries).
|
||||||
if (!CoinsTip().Flush())
|
if (!CoinsTip().Flush())
|
||||||
@ -3639,7 +3641,7 @@ static bool FindBlockPos(FlatFilePos &pos, unsigned int nAddSize, unsigned int n
|
|||||||
bool out_of_space;
|
bool out_of_space;
|
||||||
size_t bytes_allocated = BlockFileSeq().Allocate(pos, nAddSize, out_of_space);
|
size_t bytes_allocated = BlockFileSeq().Allocate(pos, nAddSize, out_of_space);
|
||||||
if (out_of_space) {
|
if (out_of_space) {
|
||||||
return AbortNode("Disk space is low!", _("Error: Disk space is low!"));
|
return AbortNode("Disk space is too low!", _("Error: Disk space is too low!"), CClientUIInterface::MSG_NOPREFIX);
|
||||||
}
|
}
|
||||||
if (bytes_allocated != 0 && fPruneMode) {
|
if (bytes_allocated != 0 && fPruneMode) {
|
||||||
fCheckForPruning = true;
|
fCheckForPruning = true;
|
||||||
@ -3663,7 +3665,7 @@ static bool FindUndoPos(CValidationState &state, int nFile, FlatFilePos &pos, un
|
|||||||
bool out_of_space;
|
bool out_of_space;
|
||||||
size_t bytes_allocated = UndoFileSeq().Allocate(pos, nAddSize, out_of_space);
|
size_t bytes_allocated = UndoFileSeq().Allocate(pos, nAddSize, out_of_space);
|
||||||
if (out_of_space) {
|
if (out_of_space) {
|
||||||
return AbortNode(state, "Disk space is low!", _("Error: Disk space is low!"));
|
return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!"), CClientUIInterface::MSG_NOPREFIX);
|
||||||
}
|
}
|
||||||
if (bytes_allocated != 0 && fPruneMode) {
|
if (bytes_allocated != 0 && fPruneMode) {
|
||||||
fCheckForPruning = true;
|
fCheckForPruning = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user