From 57ab1a410f9cb3534bb403e034743505758579d8 Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Mon, 2 Sep 2024 13:46:13 +0300 Subject: viewer#2411 A bit more coverage for font buffer --- indra/newview/llpanelmarketplaceinbox.cpp | 44 ++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 15 deletions(-) (limited to 'indra/newview/llpanelmarketplaceinbox.cpp') diff --git a/indra/newview/llpanelmarketplaceinbox.cpp b/indra/newview/llpanelmarketplaceinbox.cpp index 35961da579..d10e12d3a8 100644 --- a/indra/newview/llpanelmarketplaceinbox.cpp +++ b/indra/newview/llpanelmarketplaceinbox.cpp @@ -52,6 +52,8 @@ LLPanelMarketplaceInbox::LLPanelMarketplaceInbox(const Params& p) , mInboxButton(NULL) , mInventoryPanel(NULL) , mSavedFolderState(NULL) + , mLastItemCount(-1) + , mLastFreshItemCount(-1) { mSavedFolderState = new LLSaveFolderState(); mSavedFolderState->setApply(false); @@ -253,28 +255,40 @@ void LLPanelMarketplaceInbox::draw() llassert(mFreshCountCtrl != NULL); - if (item_count > 0) + if (mLastItemCount != item_count) { - std::string item_count_str = llformat("%d", item_count); - - LLStringUtil::format_map_t args; - args["[NUM]"] = item_count_str; - mInboxButton->setLabel(getString("InboxLabelWithArg", args)); - - // set green text to fresh item count - U32 fresh_item_count = getFreshItemCount(); - mFreshCountCtrl->setVisible((fresh_item_count > 0)); + mLastItemCount = item_count; + if (item_count > 0) + { + std::string item_count_str = llformat("%d", item_count); - if (fresh_item_count > 0) + LLStringUtil::format_map_t args; + args["[NUM]"] = item_count_str; + // setLabel is expensive, causes buffer regeneration + mInboxButton->setLabel(getString("InboxLabelWithArg", args)); + } + else { - mFreshCountCtrl->setTextArg("[NUM]", llformat("%d", fresh_item_count)); + mInboxButton->setLabel(getString("InboxLabelNoArg")); + + mFreshCountCtrl->setVisible(false); } } - else + + if (item_count > 0) { - mInboxButton->setLabel(getString("InboxLabelNoArg")); + // set green text to fresh item count + U32 fresh_item_count = getFreshItemCount(); + if (mLastFreshItemCount != fresh_item_count) + { + mLastFreshItemCount = fresh_item_count; + mFreshCountCtrl->setVisible((fresh_item_count > 0)); - mFreshCountCtrl->setVisible(false); + if (fresh_item_count > 0) + { + mFreshCountCtrl->setTextArg("[NUM]", llformat("%d", fresh_item_count)); + } + } } LLPanel::draw(); -- cgit v1.2.3