From 72c11c0e578b466eccc64e15fcaeb8d977c15e70 Mon Sep 17 00:00:00 2001 From: Stinson Linden Date: Wed, 30 Apr 2014 01:45:09 +0100 Subject: MAINT-4009: Patching another memory leak in LLBadgeOwner that indirectly was also causing leaks in llimage. --- indra/llui/llbadgeowner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/llui/llbadgeowner.cpp') diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp index 1860a05edd..9b2a9569f7 100755 --- a/indra/llui/llbadgeowner.cpp +++ b/indra/llui/llbadgeowner.cpp @@ -45,6 +45,7 @@ void LLBadgeOwner::initBadgeParams(const LLBadge::Params& p) if (!p.equals(LLUICtrlFactory::getDefaultParams())) { mBadge = createBadge(p); + addBadgeToParentPanel(); } } @@ -53,7 +54,6 @@ void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) if (mBadge == NULL) { mBadge = createBadge(LLUICtrlFactory::getDefaultParams()); - addBadgeToParentPanel(); } -- cgit v1.2.3 From 51e0cc8140a2cbe92363cb902144ccc9bf34b7c7 Mon Sep 17 00:00:00 2001 From: Stinson Linden Date: Sat, 31 May 2014 02:30:12 +0100 Subject: MAINT-4114: Refactoring the LLBadge code to ensure a parent view always has the badge (to preserve memory cleanliness), but to also allow for badge reparenting so that the NEW badge works in the inventory window. This change relates to 9e0d629da1487f850beb2767bd47734c4ccc393e. --- indra/llui/llbadgeowner.cpp | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) (limited to 'indra/llui/llbadgeowner.cpp') diff --git a/indra/llui/llbadgeowner.cpp b/indra/llui/llbadgeowner.cpp index 9b2a9569f7..55e64bb940 100755 --- a/indra/llui/llbadgeowner.cpp +++ b/indra/llui/llbadgeowner.cpp @@ -35,8 +35,9 @@ // LLBadgeOwner::LLBadgeOwner(LLHandle< LLView > viewHandle) - : mBadge(NULL) - , mBadgeOwnerView(viewHandle) + : mHasBadgeHolderParent(false), + mBadge(NULL), + mBadgeOwnerView(viewHandle) { } @@ -45,31 +46,12 @@ void LLBadgeOwner::initBadgeParams(const LLBadge::Params& p) if (!p.equals(LLUICtrlFactory::getDefaultParams())) { mBadge = createBadge(p); - addBadgeToParentPanel(); - } -} - -void LLBadgeOwner::setBadgeLabel(const LLStringExplicit& label) -{ - if (mBadge == NULL) - { - mBadge = createBadge(LLUICtrlFactory::getDefaultParams()); - addBadgeToParentPanel(); - } + mHasBadgeHolderParent = false; - if (mBadge) - { - mBadge->setLabel(label); - - // - // Push the badge to the front so it renders on top - // - - LLView * parent = mBadge->getParent(); - - if (parent) + LLView * owner_view = mBadgeOwnerView.get(); + if (owner_view) { - parent->sendChildToFront(mBadge); + mBadge->addToView(owner_view); } } } @@ -82,10 +64,8 @@ void LLBadgeOwner::setBadgeVisibility(bool visible) } } -bool LLBadgeOwner::addBadgeToParentPanel() +void LLBadgeOwner::addBadgeToParentHolder() { - bool badge_added = false; - LLView * owner_view = mBadgeOwnerView.get(); if (mBadge && owner_view) @@ -110,16 +90,9 @@ bool LLBadgeOwner::addBadgeToParentPanel() if (badge_holder) { - badge_added = badge_holder->addBadge(mBadge); - } - else - { - // Badge parent is fallback badge owner if no valid holder exists in the hierarchy - badge_added = mBadge->addToView(owner_view); + mHasBadgeHolderParent = badge_holder->addBadge(mBadge); } } - - return badge_added; } LLBadge* LLBadgeOwner::createBadge(const LLBadge::Params& p) -- cgit v1.2.3