From 50e01ee620458a7204c234697efeab1c137018b9 Mon Sep 17 00:00:00 2001 From: xanatos Date: Fri, 28 Sep 2012 14:57:07 +0300 Subject: [PATCH] toHTML won't add empty wtx.mapValue elements As the code was before, toHTML added empty elements to mapValue to check for their existance. Now first it check for their existance and then for their non-emptiness. Removed a duplicated identical if There are two equal ifs, one inside another. If the first one is true, then the second one is true. --- src/qt/transactiondesc.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 3e7eca59..efc77e19 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -64,11 +64,10 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) { strHTML += "" + tr("Source") + ": " + tr("Generated") + "
"; } - else if (!wtx.mapValue["from"].empty()) + else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty()) { // Online transaction - if (!wtx.mapValue["from"].empty()) - strHTML += "" + tr("From") + ": " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "
"; + strHTML += "" + tr("From") + ": " + GUIUtil::HtmlEscape(wtx.mapValue["from"]) + "
"; } else { @@ -104,7 +103,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) // // To // - if (!wtx.mapValue["to"].empty()) + if (wtx.mapValue.count("to") && !wtx.mapValue["to"].empty()) { // Online transaction std::string strAddress = wtx.mapValue["to"]; @@ -160,7 +159,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) if (wallet->IsMine(txout)) continue; - if (wtx.mapValue["to"].empty()) + if (!wtx.mapValue.count("to") || wtx.mapValue["to"].empty()) { // Offline transaction CTxDestination address; @@ -209,9 +208,9 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx) // // Message // - if (!wtx.mapValue["message"].empty()) + if (wtx.mapValue.count("message") && !wtx.mapValue["message"].empty()) strHTML += "
" + tr("Message") + ":
" + GUIUtil::HtmlEscape(wtx.mapValue["message"], true) + "
"; - if (!wtx.mapValue["comment"].empty()) + if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty()) strHTML += "
" + tr("Comment") + ":
" + GUIUtil::HtmlEscape(wtx.mapValue["comment"], true) + "
"; strHTML += "" + tr("Transaction ID") + ": " + wtx.GetHash().ToString().c_str() + "
";