diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp
index 21367c224d34b5efec67de1fa4d1631b9fe5e220..56c9533e11b1747bcda8ef6d124e0c2467c98b7e 100755
--- a/indra/newview/llavataractions.cpp
+++ b/indra/newview/llavataractions.cpp
@@ -235,7 +235,7 @@ void LLAvatarActions::startCall(const LLUUID& id)
 }
 
 // static
-void LLAvatarActions::startAdhocCall(const uuid_vec_t& ids)
+void LLAvatarActions::startAdhocCall(const uuid_vec_t& ids, const LLUUID& floater_id)
 {
 	if (ids.size() == 0)
 	{
@@ -252,7 +252,7 @@ void LLAvatarActions::startAdhocCall(const uuid_vec_t& ids)
 	// create the new ad hoc voice session
 	const std::string title = LLTrans::getString("conference-title");
 	LLUUID session_id = gIMMgr->addSession(title, IM_SESSION_CONFERENCE_START,
-										   ids[0], id_array, true);
+										   ids[0], id_array, true, floater_id);
 	if (session_id == LLUUID::null)
 	{
 		return;
diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h
index 46830eb22c59f15cc3aee49d61a451d81a980f74..259e87c33682b94957559a67f5fed6a52cd32fb5 100644
--- a/indra/newview/llavataractions.h
+++ b/indra/newview/llavataractions.h
@@ -82,9 +82,9 @@ class LLAvatarActions
 	static void startCall(const LLUUID& id);
 
 	/**
-	 * Start an ad-hoc conference voice call with multiple users
+	 * Start an ad-hoc conference voice call with multiple users in a specific IM floater.
 	 */
-	static void startAdhocCall(const uuid_vec_t& ids);
+	static void startAdhocCall(const uuid_vec_t& ids, const LLUUID& floater_id = LLUUID::null);
 
 	/**
 	 * Start conference chat with the given avatars in a specific IM floater.
diff --git a/indra/newview/llimfloater.cpp b/indra/newview/llimfloater.cpp
index 9d3c0f98ce0ebff04880e12f83605abdc552ea13..536d0b9a23b2d279ae22413105a5ae8546588171 100644
--- a/indra/newview/llimfloater.cpp
+++ b/indra/newview/llimfloater.cpp
@@ -322,7 +322,7 @@ BOOL LLIMFloater::postBuild()
 
 void LLIMFloater::onAddButtonClicked()
 {
-       LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show(boost::bind(&LLIMFloater::onAvatarPicked, this, _1, _2), TRUE, TRUE);
+       LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show(boost::bind(&LLIMFloater::addSessionParticipants, this, _1), TRUE, TRUE);
        if (!picker)
        {
                return;
@@ -337,25 +337,6 @@ void LLIMFloater::onAddButtonClicked()
        }
 }
 
-void LLIMFloater::onAvatarPicked(const uuid_vec_t& ids, const std::vector<LLAvatarName> names)
-{
-       if (mIsP2PChat)
-       {
-               mStartConferenceInSameFloater = true;
-               onClose(false);
-
-               uuid_vec_t temp_ids;
-               temp_ids.push_back(mOtherParticipantUUID);
-               temp_ids.insert(temp_ids.end(), ids.begin(), ids.end());
-
-               LLAvatarActions::startConference(temp_ids, mSessionID);
-       }
-       else
-       {
-               inviteToSession(ids);
-       }
-}
-
 bool LLIMFloater::canAddSelectedToChat(const uuid_vec_t& uuids)
 {
        if (!mSession
@@ -388,6 +369,44 @@ bool LLIMFloater::canAddSelectedToChat(const uuid_vec_t& uuids)
        return true;
 }
 
+void LLIMFloater::addSessionParticipants(const uuid_vec_t& uuids)
+{
+	if (mIsP2PChat)
+	{
+		mStartConferenceInSameFloater = true;
+
+		uuid_vec_t temp_ids;
+
+		// Add the initial participant of a P2P session
+		temp_ids.push_back(mOtherParticipantUUID);
+		temp_ids.insert(temp_ids.end(), uuids.begin(), uuids.end());
+
+		LLVoiceChannel* voice_channel = LLIMModel::getInstance()->getVoiceChannel(mSessionID);
+
+		// first check whether this is a voice session
+		bool is_voice_call = voice_channel != NULL && voice_channel->isActive();
+
+		// then we can close the current session
+		gIMMgr->leaveSession(mSessionID);
+		LLIMConversation::onClose(false);
+
+		// Start a new ad hoc voice call if we invite new participants to a P2P call,
+		// or start a text chat otherwise.
+		if (is_voice_call)
+		{
+			LLAvatarActions::startAdhocCall(temp_ids, mSessionID);
+		}
+		else
+		{
+			LLAvatarActions::startConference(temp_ids, mSessionID);
+		}
+	}
+	else
+	{
+		inviteToSession(uuids);
+	}
+}
+
 void LLIMFloater::boundVoiceChannel()
 {
 	LLVoiceChannel* voice_channel = LLIMModel::getInstance()->getVoiceChannel(mSessionID);
@@ -1096,19 +1115,7 @@ bool LLIMFloater::dropPerson(LLUUID* person_id, bool drop)
 		res = canAddSelectedToChat(ids);
 		if(res && drop)
 		{
-			if (mIsP2PChat)
-			{
-				mStartConferenceInSameFloater = true;
-				onClose(false);
-
-				ids.push_back(mOtherParticipantUUID);
-
-				LLAvatarActions::startConference(ids, mSessionID);
-			}
-			else
-			{
-				inviteToSession(ids);
-			}
+			addSessionParticipants(ids);
 		}
 	}
 
diff --git a/indra/newview/llimfloater.h b/indra/newview/llimfloater.h
index 23f9e75e215a58809251cb0e739afb01068510e4..2e8fc84746ec583324e0619de47e0c7b72fee643 100644
--- a/indra/newview/llimfloater.h
+++ b/indra/newview/llimfloater.h
@@ -152,7 +152,7 @@ class LLIMFloater
 	static void onInputEditorKeystroke(LLTextEditor* caller, void* userdata);
 	void setTyping(bool typing);
 	void onAddButtonClicked();
-	void onAvatarPicked(const uuid_vec_t& ids, const std::vector<LLAvatarName> names);
+	void addSessionParticipants(const uuid_vec_t& uuids);
 	bool canAddSelectedToChat(const uuid_vec_t& uuids);
 
 	void onCallButtonClicked();
diff --git a/indra/newview/llpanelpeoplemenus.cpp b/indra/newview/llpanelpeoplemenus.cpp
index ac2109dda488a43246fdc9b3cc2cbc1c907e95f2..c9eebe24d38ef9232d5ce4a29e3688e0f6edfb95 100644
--- a/indra/newview/llpanelpeoplemenus.cpp
+++ b/indra/newview/llpanelpeoplemenus.cpp
@@ -82,7 +82,7 @@ LLContextMenu* NearbyMenu::createMenu()
 
 		// registrar.add("Avatar.AddFriend",	boost::bind(&LLAvatarActions::requestFriendshipDialog,	mUUIDs)); // *TODO: unimplemented
 		registrar.add("Avatar.IM",			boost::bind(&LLAvatarActions::startConference,			mUUIDs, LLUUID::null));
-		registrar.add("Avatar.Call",		boost::bind(&LLAvatarActions::startAdhocCall,			mUUIDs));
+		registrar.add("Avatar.Call",		boost::bind(&LLAvatarActions::startAdhocCall,			mUUIDs, LLUUID::null));
 		registrar.add("Avatar.OfferTeleport",	boost::bind(&NearbyMenu::offerTeleport,					this));
 		registrar.add("Avatar.RemoveFriend",boost::bind(&LLAvatarActions::removeFriendsDialog,		mUUIDs));
 		// registrar.add("Avatar.Share",		boost::bind(&LLAvatarActions::startIM,					mUUIDs)); // *TODO: unimplemented