From f9e0831ba04f99335bfb494a22435446dc0852de Mon Sep 17 00:00:00 2001
From: AlexanderP ProductEngine <apaschenko@productengine.com>
Date: Mon, 24 Sep 2012 18:57:04 +0300
Subject: CHUI-355 FIXED Nearby chat entries do not appear in torn off nearby
 chat window when opening from a toast: moved setIsSingleInstance() from
 constructor to postBuild() for prevent of a resetting it in buildFromXML();
 implemented correct set of mReuseInstance; changed type of the key of
 LLIMConversation from LLUUID() to LLSD()

---
 indra/llui/llfloater.cpp           | 5 +++++
 indra/llui/llfloater.h             | 7 ++++---
 indra/newview/llimconversation.cpp | 4 ++--
 indra/newview/llimconversation.h   | 2 +-
 indra/newview/llnearbychat.cpp     | 7 +++----
 indra/newview/llnearbychat.h       | 4 ++--
 6 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/indra/llui/llfloater.cpp b/indra/llui/llfloater.cpp
index 029c47c726..58b17f74a8 100644
--- a/indra/llui/llfloater.cpp
+++ b/indra/llui/llfloater.cpp
@@ -240,6 +240,7 @@ LLFloater::LLFloater(const LLSD& key, const LLFloater::Params& p)
 	mTitle(p.title),
 	mShortTitle(p.short_title),
 	mSingleInstance(p.single_instance),
+	mIsReuseInitialized(p.reuse_instance.isProvided()),
 	mReuseInstance(p.reuse_instance.isProvided() ? p.reuse_instance : p.single_instance), // reuse single-instance floaters by default
 	mKey(key),
 	mCanTearOff(p.can_tear_off),
@@ -631,6 +632,10 @@ void LLFloater::setVisible( BOOL visible )
 void LLFloater::setIsSingleInstance(BOOL is_single_instance)
 {
 	mSingleInstance = is_single_instance;
+	if (!mIsReuseInitialized)
+	{
+		mReuseInstance = is_single_instance; // reuse single-instance floaters by default
+	}
 }
 
 
diff --git a/indra/llui/llfloater.h b/indra/llui/llfloater.h
index 4b738f88ea..07b79d5523 100644
--- a/indra/llui/llfloater.h
+++ b/indra/llui/llfloater.h
@@ -447,9 +447,10 @@ private:
 	LLUIString		mTitle;
 	LLUIString		mShortTitle;
 	
-	BOOL			mSingleInstance;	// TRUE if there is only ever one instance of the floater
-	bool			mReuseInstance;		// true if we want to hide the floater when we close it instead of destroying it
-	std::string		mInstanceName;		// Store the instance name so we can remove ourselves from the list
+	BOOL			mSingleInstance;	  // TRUE if there is only ever one instance of the floater
+	bool			mReuseInstance;		  // true if we want to hide the floater when we close it instead of destroying it
+    bool            mIsReuseInitialized;  // true if mReuseInstance already set from parameters
+	std::string		mInstanceName;		  // Store the instance name so we can remove ourselves from the list
 	
 	BOOL			mCanTearOff;
 	BOOL			mCanMinimize;
diff --git a/indra/newview/llimconversation.cpp b/indra/newview/llimconversation.cpp
index 3ca93b1b07..2ad7f9b193 100644
--- a/indra/newview/llimconversation.cpp
+++ b/indra/newview/llimconversation.cpp
@@ -42,13 +42,13 @@
 
 const F32 REFRESH_INTERVAL = 0.2f;
 
-LLIMConversation::LLIMConversation(const LLUUID& session_id)
+LLIMConversation::LLIMConversation(const LLSD& session_id)
   : LLTransientDockableFloater(NULL, true, session_id)
   ,  mIsP2PChat(false)
   ,  mExpandCollapseBtn(NULL)
   ,  mTearOffBtn(NULL)
   ,  mCloseBtn(NULL)
-  ,  mSessionID(session_id)
+  ,  mSessionID(session_id.asUUID())
   , mParticipantList(NULL)
   , mChatHistory(NULL)
   , mInputEditor(NULL)
diff --git a/indra/newview/llimconversation.h b/indra/newview/llimconversation.h
index bad5eaa99f..c54081d316 100644
--- a/indra/newview/llimconversation.h
+++ b/indra/newview/llimconversation.h
@@ -47,7 +47,7 @@ class LLIMConversation
 public:
 	LOG_CLASS(LLIMConversation);
 
-	LLIMConversation(const LLUUID& session_id);
+	LLIMConversation(const LLSD& session_id);
 	~LLIMConversation();
 
 	// reload all message with new settings of visual modes
diff --git a/indra/newview/llnearbychat.cpp b/indra/newview/llnearbychat.cpp
index 76626bd5a6..71c4938ae9 100644
--- a/indra/newview/llnearbychat.cpp
+++ b/indra/newview/llnearbychat.cpp
@@ -88,7 +88,7 @@ static LLChatTypeTrigger sChatTypeTriggers[] = {
 
 
 LLNearbyChat::LLNearbyChat(const LLSD& llsd)
-:	LLIMConversation(llsd.asUUID()),
+:	LLIMConversation(llsd),
 	//mOutputMonitor(NULL),
 	mSpeakerMgr(NULL),
 	mExpandedHeight(COLLAPSED_HEIGHT + EXPANDED_HEIGHT)
@@ -96,16 +96,15 @@ LLNearbyChat::LLNearbyChat(const LLSD& llsd)
     mIsP2PChat = false;
 	mIsNearbyChat = true;
 	setIsChrome(TRUE);
-	mKey = LLSD(LLUUID());
 	mSpeakerMgr = LLLocalSpeakerMgr::getInstance();
 	mSessionID = LLUUID();
-	setName("nearby_chat");
-	setIsSingleInstance(TRUE);
 }
 
+
 //virtual
 BOOL LLNearbyChat::postBuild()
 {
+    setIsSingleInstance(TRUE);
     BOOL result = LLIMConversation::postBuild();
 	mInputEditor->setCommitCallback(boost::bind(&LLNearbyChat::onChatBoxCommit, this));
 	mInputEditor->setKeystrokeCallback(boost::bind(&onChatBoxKeystroke, _1, this));
diff --git a/indra/newview/llnearbychat.h b/indra/newview/llnearbychat.h
index 648098113a..da1b58e326 100644
--- a/indra/newview/llnearbychat.h
+++ b/indra/newview/llnearbychat.h
@@ -45,8 +45,8 @@ class LLNearbyChat
 {
 public:
 	// constructor for inline chat-bars (e.g. hosted in chat history window)
-	LLNearbyChat(const LLSD& key = LLSD());
-	~LLNearbyChat() {}
+	LLNearbyChat(const LLSD& key = LLSD(LLUUID()));
+	~LLNearbyChat() {};
 
 	/*virtual*/ BOOL postBuild();
 	/*virtual*/ void onOpen(const LLSD& key);
-- 
cgit v1.2.3