CHUI-475: Ensuring that objects that query the avatar name cache with a callback store the connection and disconnect on object destruction. This should help resolve some of the heap corruption we are seeing.
parent
b9116764a9
commit
6e2b3527cc
|
|
@ -1787,22 +1787,18 @@ std::ostream& operator<<(std::ostream& s, const LLNotification& notification)
|
|||
return s;
|
||||
}
|
||||
|
||||
//static
|
||||
void LLPostponedNotification::lookupName(LLPostponedNotification* thiz,
|
||||
const LLUUID& id,
|
||||
void LLPostponedNotification::lookupName(const LLUUID& id,
|
||||
bool is_group)
|
||||
{
|
||||
if (is_group)
|
||||
{
|
||||
gCacheName->getGroup(id,
|
||||
boost::bind(&LLPostponedNotification::onGroupNameCache,
|
||||
thiz, _1, _2, _3));
|
||||
this, _1, _2, _3));
|
||||
}
|
||||
else
|
||||
{
|
||||
LLAvatarNameCache::get(id,
|
||||
boost::bind(&LLPostponedNotification::onAvatarNameCache,
|
||||
thiz, _1, _2));
|
||||
fetchAvatarName(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1813,6 +1809,20 @@ void LLPostponedNotification::onGroupNameCache(const LLUUID& id,
|
|||
finalizeName(full_name);
|
||||
}
|
||||
|
||||
void LLPostponedNotification::fetchAvatarName(const LLUUID& id)
|
||||
{
|
||||
if (mAvatarNameCacheConnection.connected())
|
||||
{
|
||||
mAvatarNameCacheConnection.disconnect();
|
||||
}
|
||||
|
||||
if (id.notNull())
|
||||
{
|
||||
mAvatarNameCacheConnection = LLAvatarNameCache::get(id,
|
||||
boost::bind(&LLPostponedNotification::onAvatarNameCache, this, _1, _2));
|
||||
}
|
||||
}
|
||||
|
||||
void LLPostponedNotification::onAvatarNameCache(const LLUUID& agent_id,
|
||||
const LLAvatarName& av_name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/type_traits.hpp>
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include "llevents.h"
|
||||
#include "llfunctorregistry.h"
|
||||
|
|
@ -972,14 +973,15 @@ public:
|
|||
thiz->mParams = params;
|
||||
|
||||
// Avoid header file dependency on llcachename.h
|
||||
lookupName(thiz, id, is_group);
|
||||
thiz->lookupName(id, is_group);
|
||||
}
|
||||
|
||||
private:
|
||||
static void lookupName(LLPostponedNotification* thiz, const LLUUID& id, bool is_group);
|
||||
void lookupName(const LLUUID& id, bool is_group);
|
||||
// only used for groups
|
||||
void onGroupNameCache(const LLUUID& id, const std::string& full_name, bool is_group);
|
||||
// only used for avatars
|
||||
void fetchAvatarName(const LLUUID& id);
|
||||
void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name);
|
||||
// used for both group and avatar names
|
||||
void finalizeName(const std::string& name);
|
||||
|
|
@ -990,8 +992,19 @@ private:
|
|||
}
|
||||
|
||||
protected:
|
||||
LLPostponedNotification() {}
|
||||
virtual ~LLPostponedNotification() {}
|
||||
LLPostponedNotification()
|
||||
: mParams(),
|
||||
mName(),
|
||||
mAvatarNameCacheConnection()
|
||||
{}
|
||||
|
||||
virtual ~LLPostponedNotification()
|
||||
{
|
||||
if (mAvatarNameCacheConnection.connected())
|
||||
{
|
||||
mAvatarNameCacheConnection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Abstract method provides possibility to modify notification parameters and
|
||||
|
|
@ -1002,6 +1015,7 @@ protected:
|
|||
|
||||
LLNotification::Params mParams;
|
||||
std::string mName;
|
||||
boost::signals2::connection mAvatarNameCacheConnection;
|
||||
};
|
||||
|
||||
// Stores only persistent notifications.
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "llavatariconctrl.h"
|
||||
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
// viewer includes
|
||||
#include "llagent.h"
|
||||
#include "llavatarconstants.h"
|
||||
|
|
@ -148,9 +150,13 @@ LLAvatarIconCtrl::Params::Params()
|
|||
|
||||
|
||||
LLAvatarIconCtrl::LLAvatarIconCtrl(const LLAvatarIconCtrl::Params& p)
|
||||
: LLIconCtrl(p),
|
||||
: LLIconCtrl(p),
|
||||
LLAvatarPropertiesObserver(),
|
||||
mAvatarId(),
|
||||
mFullName(),
|
||||
mDrawTooltip(p.draw_tooltip),
|
||||
mDefaultIconName(p.default_icon_name)
|
||||
mDefaultIconName(p.default_icon_name),
|
||||
mAvatarNameCacheConnection()
|
||||
{
|
||||
mPriority = LLViewerFetchedTexture::BOOST_ICON;
|
||||
|
||||
|
|
@ -203,6 +209,11 @@ LLAvatarIconCtrl::~LLAvatarIconCtrl()
|
|||
LLAvatarPropertiesProcessor::getInstance()->removeObserver(mAvatarId, this);
|
||||
// Name callbacks will be automatically disconnected since LLUICtrl is trackable
|
||||
}
|
||||
|
||||
if (mAvatarNameCacheConnection.connected())
|
||||
{
|
||||
mAvatarNameCacheConnection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
//virtual
|
||||
|
|
@ -245,9 +256,19 @@ void LLAvatarIconCtrl::setValue(const LLSD& value)
|
|||
LLIconCtrl::setValue(value);
|
||||
}
|
||||
|
||||
if (mAvatarId != LLUUID::null)
|
||||
fetchAvatarName();
|
||||
}
|
||||
|
||||
void LLAvatarIconCtrl::fetchAvatarName()
|
||||
{
|
||||
if (mAvatarNameCacheConnection.connected())
|
||||
{
|
||||
LLAvatarNameCache::get(mAvatarId, boost::bind(&LLAvatarIconCtrl::onAvatarNameCache, this, _1, _2));
|
||||
mAvatarNameCacheConnection.disconnect();
|
||||
}
|
||||
|
||||
if (mAvatarId.notNull())
|
||||
{
|
||||
mAvatarNameCacheConnection = LLAvatarNameCache::get(mAvatarId, boost::bind(&LLAvatarIconCtrl::onAvatarNameCache, this, _1, _2));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#ifndef LL_LLAVATARICONCTRL_H
|
||||
#define LL_LLAVATARICONCTRL_H
|
||||
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include "lliconctrl.h"
|
||||
#include "llavatarpropertiesprocessor.h"
|
||||
#include "llviewermenu.h"
|
||||
|
|
@ -86,20 +88,24 @@ public:
|
|||
// LLAvatarPropertiesProcessor observer trigger
|
||||
virtual void processProperties(void* data, EAvatarProcessorType type);
|
||||
|
||||
void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name);
|
||||
|
||||
const LLUUID& getAvatarId() const { return mAvatarId; }
|
||||
const std::string& getFullName() const { return mFullName; }
|
||||
|
||||
void setDrawTooltip(bool value) { mDrawTooltip = value;}
|
||||
|
||||
protected:
|
||||
LLUUID mAvatarId;
|
||||
std::string mFullName;
|
||||
bool mDrawTooltip;
|
||||
std::string mDefaultIconName;
|
||||
LLUUID mAvatarId;
|
||||
std::string mFullName;
|
||||
bool mDrawTooltip;
|
||||
std::string mDefaultIconName;
|
||||
|
||||
bool updateFromCache();
|
||||
|
||||
private:
|
||||
void fetchAvatarName();
|
||||
void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name);
|
||||
|
||||
boost::signals2::connection mAvatarNameCacheConnection;
|
||||
};
|
||||
|
||||
#endif // LL_LLAVATARICONCTRL_H
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include "llviewerprecompiledheaders.h"
|
||||
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include "llavataractions.h"
|
||||
#include "llavatarlistitem.h"
|
||||
|
||||
|
|
@ -59,7 +61,8 @@ LLAvatarListItem::Params::Params()
|
|||
|
||||
|
||||
LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/)
|
||||
: LLPanel(),
|
||||
: LLPanel(),
|
||||
LLFriendObserver(),
|
||||
mAvatarIcon(NULL),
|
||||
mAvatarName(NULL),
|
||||
mLastInteractionTime(NULL),
|
||||
|
|
@ -74,7 +77,8 @@ LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/)
|
|||
mShowInfoBtn(true),
|
||||
mShowProfileBtn(true),
|
||||
mShowPermissions(false),
|
||||
mHovered(false)
|
||||
mHovered(false),
|
||||
mAvatarNameCacheConnection()
|
||||
{
|
||||
if (not_from_ui_factory)
|
||||
{
|
||||
|
|
@ -87,7 +91,14 @@ LLAvatarListItem::LLAvatarListItem(bool not_from_ui_factory/* = true*/)
|
|||
LLAvatarListItem::~LLAvatarListItem()
|
||||
{
|
||||
if (mAvatarId.notNull())
|
||||
{
|
||||
LLAvatarTracker::instance().removeParticularFriendObserver(mAvatarId, this);
|
||||
}
|
||||
|
||||
if (mAvatarNameCacheConnection.connected())
|
||||
{
|
||||
mAvatarNameCacheConnection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
BOOL LLAvatarListItem::postBuild()
|
||||
|
|
@ -130,6 +141,19 @@ BOOL LLAvatarListItem::postBuild()
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void LLAvatarListItem::fetchAvatarName()
|
||||
{
|
||||
if (mAvatarNameCacheConnection.connected())
|
||||
{
|
||||
mAvatarNameCacheConnection.disconnect();
|
||||
}
|
||||
|
||||
if (mAvatarId.notNull())
|
||||
{
|
||||
mAvatarNameCacheConnection = LLAvatarNameCache::get(getAvatarId(), boost::bind(&LLAvatarListItem::onAvatarNameCache, this, _2));
|
||||
}
|
||||
}
|
||||
|
||||
S32 LLAvatarListItem::notifyParent(const LLSD& info)
|
||||
{
|
||||
if (info.has("visibility_changed"))
|
||||
|
|
@ -260,8 +284,7 @@ void LLAvatarListItem::setAvatarId(const LLUUID& id, const LLUUID& session_id, b
|
|||
mAvatarIcon->setValue(id);
|
||||
|
||||
// Set avatar name.
|
||||
LLAvatarNameCache::get(id,
|
||||
boost::bind(&LLAvatarListItem::onAvatarNameCache, this, _2));
|
||||
fetchAvatarName();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -414,8 +437,7 @@ std::string LLAvatarListItem::getAvatarToolTip() const
|
|||
|
||||
void LLAvatarListItem::updateAvatarName()
|
||||
{
|
||||
LLAvatarNameCache::get(getAvatarId(),
|
||||
boost::bind(&LLAvatarListItem::onAvatarNameCache, this, _2));
|
||||
fetchAvatarName();
|
||||
}
|
||||
|
||||
//== PRIVATE SECITON ==========================================================
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
#ifndef LL_LLAVATARLISTITEM_H
|
||||
#define LL_LLAVATARLISTITEM_H
|
||||
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include "llpanel.h"
|
||||
#include "lloutputmonitorctrl.h"
|
||||
#include "llbutton.h"
|
||||
|
|
@ -217,6 +219,9 @@ private:
|
|||
|
||||
/// true when the mouse pointer is hovering over this item
|
||||
bool mHovered;
|
||||
|
||||
void fetchAvatarName();
|
||||
boost::signals2::connection mAvatarNameCacheConnection;
|
||||
|
||||
static bool sStaticInitialized; // this variable is introduced to improve code readability
|
||||
static S32 sLeftPadding; // padding to first left visible child (icon or name)
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
#include "llchathistory.h"
|
||||
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include "llavatarnamecache.h"
|
||||
#include "llinstantmessage.h"
|
||||
|
||||
|
|
@ -110,7 +112,8 @@ public:
|
|||
mFrom(),
|
||||
mSessionID(),
|
||||
mMinUserNameWidth(0),
|
||||
mUserNameFont(NULL)
|
||||
mUserNameFont(NULL),
|
||||
mAvatarNameCacheConnection()
|
||||
{}
|
||||
|
||||
static LLChatHistoryHeader* createInstance(const std::string& file_name)
|
||||
|
|
@ -124,6 +127,11 @@ public:
|
|||
{
|
||||
// Detach the info button so that it doesn't get destroyed (EXT-8463).
|
||||
hideInfoCtrl();
|
||||
|
||||
if (mAvatarNameCacheConnection.connected())
|
||||
{
|
||||
mAvatarNameCacheConnection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
BOOL handleMouseUp(S32 x, S32 y, MASK mask)
|
||||
|
|
@ -283,8 +291,7 @@ public:
|
|||
// Start with blank so sample data from XUI XML doesn't
|
||||
// flash on the screen
|
||||
user_name->setValue( LLSD() );
|
||||
LLAvatarNameCache::get(mAvatarID,
|
||||
boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2));
|
||||
fetchAvatarName();
|
||||
}
|
||||
else if (chat.mChatStyle == CHAT_STYLE_HISTORY ||
|
||||
mSourceType == CHAT_SOURCE_AGENT)
|
||||
|
|
@ -416,31 +423,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name)
|
||||
{
|
||||
mFrom = av_name.mDisplayName;
|
||||
|
||||
LLTextBox* user_name = getChild<LLTextBox>("user_name");
|
||||
user_name->setValue( LLSD(av_name.mDisplayName ) );
|
||||
user_name->setToolTip( av_name.mUsername );
|
||||
|
||||
if (gSavedSettings.getBOOL("NameTagShowUsernames") &&
|
||||
LLAvatarNameCache::useDisplayNames() &&
|
||||
!av_name.mIsDisplayNameDefault)
|
||||
{
|
||||
LLStyle::Params style_params_name;
|
||||
LLColor4 userNameColor = LLUIColorTable::instance().getColor("EmphasisColor");
|
||||
style_params_name.color(userNameColor);
|
||||
style_params_name.font.name("SansSerifSmall");
|
||||
style_params_name.font.style("NORMAL");
|
||||
style_params_name.readonly_color(userNameColor);
|
||||
user_name->appendText(" - " + av_name.mUsername, FALSE, style_params_name);
|
||||
}
|
||||
setToolTip( av_name.mUsername );
|
||||
// name might have changed, update width
|
||||
updateMinUserNameWidth();
|
||||
}
|
||||
|
||||
protected:
|
||||
static const S32 PADDING = 20;
|
||||
|
||||
|
|
@ -555,6 +537,45 @@ private:
|
|||
user_name->reshape(user_rect.getWidth() + delta_pos_x, user_rect.getHeight());
|
||||
}
|
||||
|
||||
void fetchAvatarName()
|
||||
{
|
||||
if (mAvatarNameCacheConnection.connected())
|
||||
{
|
||||
mAvatarNameCacheConnection.disconnect();
|
||||
}
|
||||
|
||||
if (mAvatarID.notNull())
|
||||
{
|
||||
mAvatarNameCacheConnection = LLAvatarNameCache::get(mAvatarID,
|
||||
boost::bind(&LLChatHistoryHeader::onAvatarNameCache, this, _1, _2));
|
||||
}
|
||||
}
|
||||
|
||||
void onAvatarNameCache(const LLUUID& agent_id, const LLAvatarName& av_name)
|
||||
{
|
||||
mFrom = av_name.mDisplayName;
|
||||
|
||||
LLTextBox* user_name = getChild<LLTextBox>("user_name");
|
||||
user_name->setValue( LLSD(av_name.mDisplayName ) );
|
||||
user_name->setToolTip( av_name.mUsername );
|
||||
|
||||
if (gSavedSettings.getBOOL("NameTagShowUsernames") &&
|
||||
LLAvatarNameCache::useDisplayNames() &&
|
||||
!av_name.mIsDisplayNameDefault)
|
||||
{
|
||||
LLStyle::Params style_params_name;
|
||||
LLColor4 userNameColor = LLUIColorTable::instance().getColor("EmphasisColor");
|
||||
style_params_name.color(userNameColor);
|
||||
style_params_name.font.name("SansSerifSmall");
|
||||
style_params_name.font.style("NORMAL");
|
||||
style_params_name.readonly_color(userNameColor);
|
||||
user_name->appendText(" - " + av_name.mUsername, FALSE, style_params_name);
|
||||
}
|
||||
setToolTip( av_name.mUsername );
|
||||
// name might have changed, update width
|
||||
updateMinUserNameWidth();
|
||||
}
|
||||
|
||||
protected:
|
||||
LLHandle<LLView> mPopupMenuHandleAvatar;
|
||||
LLHandle<LLView> mPopupMenuHandleObject;
|
||||
|
|
@ -569,6 +590,9 @@ protected:
|
|||
|
||||
S32 mMinUserNameWidth;
|
||||
const LLFontGL* mUserNameFont;
|
||||
|
||||
private:
|
||||
boost::signals2::connection mAvatarNameCacheConnection;
|
||||
};
|
||||
|
||||
LLUICtrl* LLChatHistoryHeader::sInfoCtrl = NULL;
|
||||
|
|
|
|||
Loading…
Reference in New Issue