From ec48cc1a40fc189de379ca3dd198e3b96395ce33 Mon Sep 17 00:00:00 2001
From: Sergei Litovchuk <slitovchuk@productengine.com>
Date: Thu, 3 Dec 2009 15:52:48 +0200
Subject: No ticket. Fixed using LLVoiceChannel::setStateChangedCallback() in
 IM Panel and IM View. - Added disconnecting signal in destructor.

--HG--
branch : product-engine
---
 indra/newview/llimview.cpp              | 6 ++++--
 indra/newview/llimview.h                | 3 +++
 indra/newview/llpanelimcontrolpanel.cpp | 9 ++++++++-
 indra/newview/llpanelimcontrolpanel.h   | 5 ++++-
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index 5481ca97cd..22cc799ef0 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -165,7 +165,7 @@ LLIMModel::LLIMSession::LLIMSession(const LLUUID& session_id, const std::string&
 
 	if(mVoiceChannel)
 	{
-		mVoiceChannel->setStateChangedCallback(boost::bind(&LLIMSession::onVoiceChannelStateChanged, this, _1, _2));
+		mVoiceChannelStateChangeConnection = mVoiceChannel->setStateChangedCallback(boost::bind(&LLIMSession::onVoiceChannelStateChanged, this, _1, _2));
 	}
 	mSpeakers = new LLIMSpeakerMgr(mVoiceChannel);
 
@@ -270,9 +270,11 @@ LLIMModel::LLIMSession::~LLIMSession()
 		}
 	}
 
+	mVoiceChannelStateChangeConnection.disconnect();
+
 	// HAVE to do this here -- if it happens in the LLVoiceChannel destructor it will call the wrong version (since the object's partially deconstructed at that point).
 	mVoiceChannel->deactivate();
-	
+
 	delete mVoiceChannel;
 	mVoiceChannel = NULL;
 }
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index 66f92c83a5..8a0f57deb0 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -72,6 +72,9 @@ public:
 		LLUUID mOtherParticipantID;
 		std::vector<LLUUID> mInitialTargetIDs;
 
+		// connection to voice channel state change signal
+		boost::signals2::connection mVoiceChannelStateChangeConnection;
+
 		//does NOT include system messages
 		S32 mNumUnread;
 
diff --git a/indra/newview/llpanelimcontrolpanel.cpp b/indra/newview/llpanelimcontrolpanel.cpp
index 405c95fc22..8c19865550 100644
--- a/indra/newview/llpanelimcontrolpanel.cpp
+++ b/indra/newview/llpanelimcontrolpanel.cpp
@@ -71,6 +71,11 @@ void LLPanelChatControlPanel::onVoiceChannelStateChanged(const LLVoiceChannel::E
 	childSetVisible("call_btn", ! is_call_started);
 }
 
+LLPanelChatControlPanel::~LLPanelChatControlPanel()
+{
+	mVoiceChannelStateChangeConnection.disconnect();
+}
+
 BOOL LLPanelChatControlPanel::postBuild()
 {
 	childSetAction("call_btn", boost::bind(&LLPanelChatControlPanel::onCallButtonClicked, this));
@@ -113,7 +118,9 @@ void LLPanelChatControlPanel::setSessionId(const LLUUID& session_id)
 	mSessionId = session_id;
 	LLVoiceChannel* voice_channel = LLIMModel::getInstance()->getVoiceChannel(mSessionId);
 	if(voice_channel)
-		voice_channel->setStateChangedCallback(boost::bind(&LLPanelChatControlPanel::onVoiceChannelStateChanged, this, _1, _2));
+	{
+		mVoiceChannelStateChangeConnection = voice_channel->setStateChangedCallback(boost::bind(&LLPanelChatControlPanel::onVoiceChannelStateChanged, this, _1, _2));
+	}
 }
 
 LLPanelIMControlPanel::LLPanelIMControlPanel()
diff --git a/indra/newview/llpanelimcontrolpanel.h b/indra/newview/llpanelimcontrolpanel.h
index a590232a0b..871779b273 100644
--- a/indra/newview/llpanelimcontrolpanel.h
+++ b/indra/newview/llpanelimcontrolpanel.h
@@ -47,7 +47,7 @@ public:
 	LLPanelChatControlPanel() :
 		mSessionId(LLUUID()),
 		mInitialized(false) {};
-	~LLPanelChatControlPanel() {};
+	~LLPanelChatControlPanel();
 
 	virtual BOOL postBuild();
 	virtual void draw();
@@ -64,6 +64,9 @@ public:
 private:
 	LLUUID mSessionId;
 	bool   mInitialized;
+
+	// connection to voice channel state change signal
+	boost::signals2::connection mVoiceChannelStateChangeConnection;
 };
 
 
-- 
cgit v1.2.3