From 204393bd993948a13f67cd8543bc151525bf6303 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Thu, 24 Jul 2014 11:33:04 +0200 Subject: [PATCH] Properly disconnect RlvBehaviorCallbacks in contacts and quickprefs floater --- indra/newview/fsfloatercontacts.cpp | 10 ++++++++-- indra/newview/fsfloatercontacts.h | 1 + indra/newview/quickprefs.cpp | 9 +++++++-- indra/newview/quickprefs.h | 1 + 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/indra/newview/fsfloatercontacts.cpp b/indra/newview/fsfloatercontacts.cpp index eef4d0f527..19e17a4afd 100644 --- a/indra/newview/fsfloatercontacts.cpp +++ b/indra/newview/fsfloatercontacts.cpp @@ -91,7 +91,8 @@ FSFloaterContacts::FSFloaterContacts(const LLSD& seed) mGroupList(NULL), mAllowRightsChange(TRUE), mNumRightsChanged(0), - mSortByUserName(LLCachedControl(gSavedSettings,"FSSortContactsByUserName", FALSE)) + mSortByUserName(LLCachedControl(gSavedSettings,"FSSortContactsByUserName", FALSE)), + mRlvBehaviorCallbackConnection() { mObserver = new LLLocalFriendsObserver(this); LLAvatarTracker::instance().addObserver(mObserver); @@ -105,6 +106,11 @@ FSFloaterContacts::~FSFloaterContacts() LLVoiceClient::getInstance()->removeObserver(mObserver); LLAvatarTracker::instance().removeObserver(mObserver); delete mObserver; + + if (mRlvBehaviorCallbackConnection.connected()) + { + mRlvBehaviorCallbackConnection.disconnect(); + } } BOOL FSFloaterContacts::postBuild() @@ -165,7 +171,7 @@ BOOL FSFloaterContacts::postBuild() mGroupsTab->childSetAction("invite_btn", boost::bind(&FSFloaterContacts::onGroupInviteButtonClicked, this)); mGroupsTab->setDefaultBtn("chat_btn"); - gRlvHandler.setBehaviourCallback(boost::bind(&FSFloaterContacts::updateRlvRestrictions, this, _1)); + mRlvBehaviorCallbackConnection = gRlvHandler.setBehaviourCallback(boost::bind(&FSFloaterContacts::updateRlvRestrictions, this, _1)); return TRUE; } diff --git a/indra/newview/fsfloatercontacts.h b/indra/newview/fsfloatercontacts.h index d957d75223..d4ee37d235 100644 --- a/indra/newview/fsfloatercontacts.h +++ b/indra/newview/fsfloatercontacts.h @@ -146,6 +146,7 @@ private: void childShowTab(const std::string& id, const std::string& tabname); void updateRlvRestrictions(ERlvBehaviour behavior); + boost::signals2::connection mRlvBehaviorCallbackConnection; }; diff --git a/indra/newview/quickprefs.cpp b/indra/newview/quickprefs.cpp index 775066c23b..46ef93150b 100644 --- a/indra/newview/quickprefs.cpp +++ b/indra/newview/quickprefs.cpp @@ -95,7 +95,8 @@ FloaterQuickPrefs::QuickPrefsXMLEntry::QuickPrefsXMLEntry() // FloaterQuickPrefs::FloaterQuickPrefs(const LLSD& key) -: LLTransientDockableFloater(NULL, true, key) +: LLTransientDockableFloater(NULL, true, key), + mRlvBehaviorCallbackConnection() { // For Phototools mCommitCallbackRegistrar.add("Quickprefs.ShaderChanged", boost::bind(&handleSetShaderChanged, LLSD())); @@ -103,6 +104,10 @@ FloaterQuickPrefs::FloaterQuickPrefs(const LLSD& key) FloaterQuickPrefs::~FloaterQuickPrefs() { + if (mRlvBehaviorCallbackConnection.connected()) + { + mRlvBehaviorCallbackConnection.disconnect(); + } } void FloaterQuickPrefs::onOpen(const LLSD& key) @@ -202,7 +207,7 @@ void FloaterQuickPrefs::initCallbacks() gSavedSettings.getControl("QuickPrefsEditMode")->getSignal()->connect(boost::bind(&FloaterQuickPrefs::onEditModeChanged, this)); // Dynamic Quickprefs } - gRlvHandler.setBehaviourCallback(boost::bind(&FloaterQuickPrefs::updateRlvRestrictions, this, _1, _2)); + mRlvBehaviorCallbackConnection = gRlvHandler.setBehaviourCallback(boost::bind(&FloaterQuickPrefs::updateRlvRestrictions, this, _1, _2)); } void FloaterQuickPrefs::loadPresets() diff --git a/indra/newview/quickprefs.h b/indra/newview/quickprefs.h index 54bd89f41d..960a945984 100644 --- a/indra/newview/quickprefs.h +++ b/indra/newview/quickprefs.h @@ -91,6 +91,7 @@ private: void onClickDayCycleNext(); void onClickResetToRegionDefault(); + boost::signals2::connection mRlvBehaviorCallbackConnection; void updateRlvRestrictions(ERlvBehaviour behavior, ERlvParamType type); void enableWindlightButtons(BOOL enable);