From d81b8884109cbeacf211282b0a08aa3aea425294 Mon Sep 17 00:00:00 2001
From: Igor Borovkov <iborovkov@productengine.com>
Date: Mon, 26 Oct 2009 16:41:47 +0200
Subject: IM: fixed remove session logic, got rid of "being session removed"
 field

--HG--
branch : product-engine
---
 indra/newview/llimview.cpp | 35 ++++++++---------------------------
 indra/newview/llimview.h   | 12 +++++-------
 2 files changed, 13 insertions(+), 34 deletions(-)

diff --git a/indra/newview/llimview.cpp b/indra/newview/llimview.cpp
index fa7e1170be..593f3a1e82 100644
--- a/indra/newview/llimview.cpp
+++ b/indra/newview/llimview.cpp
@@ -1405,10 +1405,7 @@ S32 LLIMMgr::getNumberOfUnreadIM()
 	S32 num = 0;
 	for(it = LLIMModel::sSessionsMap.begin(); it != LLIMModel::sSessionsMap.end(); ++it)
 	{
-		if((*it).first != mBeingRemovedSessionID)
-		{
-			num += (*it).second->mNumUnread;
-		}
+		num += (*it).second->mNumUnread;
 	}
 
 	return num;
@@ -1517,41 +1514,25 @@ bool LLIMMgr::leaveSession(const LLUUID& session_id)
 	return true;
 }
 
-// This removes the panel referenced by the uuid, and then restores
-// internal consistency. The internal pointer is not deleted? Did you mean
-// a pointer to the corresponding LLIMSession? Session data is cleared now.
-// Put a copy of UUID to avoid problem when passed reference becames invalid
-// if it has been come from the object removed in observer.
-void LLIMMgr::removeSession(LLUUID session_id)
+// Removes data associated with a particular session specified by session_id
+void LLIMMgr::removeSession(const LLUUID& session_id)
 {
-	if (mBeingRemovedSessionID == session_id)
-	{
-		return;
-	}
+	llassert_always(hasSession(session_id));
 	
+	//*TODO remove this floater thing when Communicate Floater is being deleted (IB)
 	LLFloaterIMPanel* floater = findFloaterBySession(session_id);
 	if(floater)
 	{
 		mFloaters.erase(floater->getHandle());
 		LLFloaterChatterBox::getInstance()->removeFloater(floater);
-		//mTabContainer->removeTabPanel(floater);
-
-		clearPendingInvitation(session_id);
-		clearPendingAgentListUpdates(session_id);
 	}
 
-	// for some purposes storing ID of a sessios that is being removed
-	mBeingRemovedSessionID = session_id;
-	notifyObserverSessionRemoved(session_id);
+	clearPendingInvitation(session_id);
+	clearPendingAgentListUpdates(session_id);
 
-	//if we don't clear session data on removing the session
-	//we can't use LLBottomTray as observer of session creation/delettion and 
-	//creating chiclets only on session created even, we need to handle chiclets creation
-	//the same way as LLFloaterIMPanels were managed.
 	LLIMModel::getInstance()->clearSession(session_id);
 
-	// now this session is completely removed
-	mBeingRemovedSessionID.setNull();
+	notifyObserverSessionRemoved(session_id);
 }
 
 void LLIMMgr::inviteToSession(
diff --git a/indra/newview/llimview.h b/indra/newview/llimview.h
index 6991017e8f..5ba54d30c3 100644
--- a/indra/newview/llimview.h
+++ b/indra/newview/llimview.h
@@ -297,10 +297,11 @@ public:
 	bool endCall(const LLUUID& session_id);
 
 private:
-	// This removes the panel referenced by the uuid, and then
-	// restores internal consistency. The internal pointer is not
-	// deleted.
-	void removeSession(LLUUID session_id);
+
+	/**
+	 * Remove data associated with a particular session specified by session_id
+	 */
+	void removeSession(const LLUUID& session_id);
 
 	// create a panel and update internal representation for
 	// consistency. Returns the pointer, caller (the class instance
@@ -341,9 +342,6 @@ private:
 
 	LLSD mPendingInvitations;
 	LLSD mPendingAgentListUpdates;
-	// ID of a session that is being removed: observers are already told
-	// that this session is being removed, but it is still present in the sessions' map
-	LLUUID	mBeingRemovedSessionID;
 };
 
 class LLIncomingCallDialog : public LLModalDialog
-- 
cgit v1.2.3