summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterimsessiontab.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterimsessiontab.cpp')
-rw-r--r--indra/newview/llfloaterimsessiontab.cpp93
1 files changed, 66 insertions, 27 deletions
diff --git a/indra/newview/llfloaterimsessiontab.cpp b/indra/newview/llfloaterimsessiontab.cpp
index 24cc398f3b..9b1fc96706 100644
--- a/indra/newview/llfloaterimsessiontab.cpp
+++ b/indra/newview/llfloaterimsessiontab.cpp
@@ -78,7 +78,7 @@ LLFloaterIMSessionTab::LLFloaterIMSessionTab(const LLSD& session_id)
mInputPanels(NULL),
mChatLayoutPanelHeight(0)
{
- setAutoFocus(FALSE);
+ setAutoFocus(false);
mSession = LLIMModel::getInstance()->findIMSession(mSessionID);
mCommitCallbackRegistrar.add("IMSession.Menu.Action",
@@ -102,6 +102,26 @@ LLFloaterIMSessionTab::LLFloaterIMSessionTab(const LLSD& session_id)
LLFloaterIMSessionTab::~LLFloaterIMSessionTab()
{
delete mRefreshTimer;
+
+ LLFloaterIMContainer* im_container = LLFloaterIMContainer::findInstance();
+ if (im_container)
+ {
+ LLParticipantList* session = dynamic_cast<LLParticipantList*>(im_container->getSessionModel(mSessionID));
+ if (session)
+ {
+ for (const conversations_widgets_map::value_type& widget_pair : mConversationsWidgets)
+ {
+ LLFolderViewItem* widget = widget_pair.second;
+ LLFolderViewModelItem* item_vmi = widget->getViewModelItem();
+ if (item_vmi && item_vmi->getNumRefs() == 1)
+ {
+ // This is the last pointer, remove participant from session
+ // before participant gets deleted on destroyView.
+ session->removeChild(item_vmi);
+ }
+ }
+ }
+ }
}
// static
@@ -141,7 +161,7 @@ LLFloaterIMSessionTab* LLFloaterIMSessionTab::getConversation(const LLUUID& uuid
};
// virtual
-void LLFloaterIMSessionTab::setVisible(BOOL visible)
+void LLFloaterIMSessionTab::setVisible(bool visible)
{
if (visible && !mHasVisibleBeenInitialized)
{
@@ -164,7 +184,7 @@ void LLFloaterIMSessionTab::setVisible(BOOL visible)
}
// virtual
-void LLFloaterIMSessionTab::setFocus(BOOL focus)
+void LLFloaterIMSessionTab::setFocus(bool focus)
{
super::setFocus(focus);
@@ -175,7 +195,7 @@ void LLFloaterIMSessionTab::setFocus(BOOL focus)
if (mInputEditor)
{
- mInputEditor->setFocus(TRUE);
+ mInputEditor->setFocus(true);
}
}
}
@@ -238,9 +258,9 @@ void LLFloaterIMSessionTab::assignResizeLimits()
}
// virtual
-BOOL LLFloaterIMSessionTab::postBuild()
+bool LLFloaterIMSessionTab::postBuild()
{
- BOOL result;
+ bool result;
mBodyStack = getChild<LLLayoutStack>("main_stack");
mParticipantListAndHistoryStack = getChild<LLLayoutStack>("im_panels");
@@ -305,8 +325,8 @@ BOOL LLFloaterIMSessionTab::postBuild()
mInputEditor->setTextExpandedCallback(boost::bind(&LLFloaterIMSessionTab::reshapeChatLayoutPanel, this));
mInputEditor->setMouseUpCallback(boost::bind(&LLFloaterIMSessionTab::onInputEditorClicked, this));
- mInputEditor->setCommitOnFocusLost( FALSE );
- mInputEditor->setPassDelete(TRUE);
+ mInputEditor->setCommitOnFocusLost(false);
+ mInputEditor->setPassDelete(true);
mInputEditor->setFont(LLViewerChat::getChatFont());
mChatLayoutPanelHeight = mChatLayoutPanel->getRect().getHeight();
@@ -453,19 +473,19 @@ void LLFloaterIMSessionTab::onInputEditorClicked()
void LLFloaterIMSessionTab::onEmojiRecentPanelToggleBtnClicked()
{
- BOOL show = mEmojiRecentPanel->getVisible() ? FALSE : TRUE;
+ bool show = mEmojiRecentPanel->getVisible() ? false : true;
if (show)
{
initEmojiRecentPanel();
}
mEmojiRecentPanel->setVisible(show);
- mInputEditor->setFocus(TRUE);
+ mInputEditor->setFocus(true);
}
void LLFloaterIMSessionTab::onEmojiPickerShowBtnClicked()
{
- mInputEditor->setFocus(TRUE);
+ mInputEditor->setFocus(true);
mInputEditor->showEmojiHelper();
}
@@ -474,8 +494,8 @@ void LLFloaterIMSessionTab::initEmojiRecentPanel()
std::list<llwchar>& recentlyUsed = LLFloaterEmojiPicker::getRecentlyUsed();
if (recentlyUsed.empty())
{
- mEmojiRecentEmptyText->setVisible(TRUE);
- mEmojiRecentIconsCtrl->setVisible(FALSE);
+ mEmojiRecentEmptyText->setVisible(true);
+ mEmojiRecentIconsCtrl->setVisible(false);
}
else
{
@@ -485,8 +505,8 @@ void LLFloaterIMSessionTab::initEmojiRecentPanel()
emojis += emoji;
}
mEmojiRecentIconsCtrl->setEmojis(emojis);
- mEmojiRecentEmptyText->setVisible(FALSE);
- mEmojiRecentIconsCtrl->setVisible(TRUE);
+ mEmojiRecentEmptyText->setVisible(false);
+ mEmojiRecentIconsCtrl->setVisible(true);
}
}
@@ -533,7 +553,6 @@ void LLFloaterIMSessionTab::appendMessage(const LLChat& chat, const LLSD& args)
{
im_box->setTimeNow(mSessionID, chat.mFromID);
}
-
LLChat& tmp_chat = const_cast<LLChat&>(chat);
if (tmp_chat.mTimeStr.empty())
@@ -638,7 +657,7 @@ void LLFloaterIMSessionTab::addConversationViewParticipant(LLConversationItem* p
mConversationsWidgets[uuid] = participant_view;
participant_view->addToFolder(mConversationsRoot);
participant_view->addToSession(mSessionID);
- participant_view->setVisible(TRUE);
+ participant_view->setVisible(true);
}
}
@@ -647,6 +666,27 @@ void LLFloaterIMSessionTab::removeConversationViewParticipant(const LLUUID& part
LLFolderViewItem* widget = get_ptr_in_map(mConversationsWidgets,participant_id);
if (widget)
{
+ LLFolderViewModelItem* item_vmi = widget->getViewModelItem();
+ if (item_vmi && item_vmi->getNumRefs() == 1)
+ {
+ // This is the last pointer, remove participant from session
+ // before participant gets deleted on destroyView.
+ //
+ // Floater (widget) and participant's view can simultaneously
+ // co-own the model, in which case view is responsible for
+ // the deletion and floater is free to clear and recreate
+ // the list, yet there are cases where only widget owns
+ // the pointer so it should do the cleanup.
+ // See "add_participant".
+ //
+ // Todo: If it keeps causing issues turn participants
+ // into LLPointers in the session
+ LLParticipantList* session = getParticipantList();
+ if (session)
+ {
+ session->removeChild(item_vmi);
+ }
+ }
widget->destroyView();
}
mConversationsWidgets.erase(participant_id);
@@ -683,7 +723,7 @@ void LLFloaterIMSessionTab::refreshConversation()
if (widget_it->second->getViewModelItem())
{
widget_it->second->refresh();
- widget_it->second->setVisible(TRUE);
+ widget_it->second->setVisible(true);
}
++widget_it;
}
@@ -928,7 +968,7 @@ void LLFloaterIMSessionTab::forceReshape()
void LLFloaterIMSessionTab::reshapeChatLayoutPanel()
{
- mChatLayoutPanel->reshape(mChatLayoutPanel->getRect().getWidth(), mInputEditor->getRect().getHeight() + mInputEditorPad, FALSE);
+ mChatLayoutPanel->reshape(mChatLayoutPanel->getRect().getWidth(), mInputEditor->getRect().getHeight() + mInputEditorPad, false);
}
// static
@@ -1089,7 +1129,7 @@ void LLFloaterIMSessionTab::onOpen(const LLSD& key)
mInputButtonPanel->setVisible(isTornOff());
- setFocus(TRUE);
+ setFocus(true);
}
@@ -1121,8 +1161,7 @@ void LLFloaterIMSessionTab::onTearOffClicked()
void LLFloaterIMSessionTab::updateGearBtn()
{
-
- BOOL prevVisibility = mGearBtn->getVisible();
+ bool prevVisibility = mGearBtn->getVisible();
mGearBtn->setVisible(checkIfTornOff() && mIsP2PChat);
@@ -1267,9 +1306,9 @@ LLView* LLFloaterIMSessionTab::getChatHistory()
return mChatHistory;
}
-BOOL LLFloaterIMSessionTab::handleKeyHere(KEY key, MASK mask )
+bool LLFloaterIMSessionTab::handleKeyHere(KEY key, MASK mask )
{
- BOOL handled = FALSE;
+ bool handled = false;
if(mask == MASK_ALT)
{
@@ -1277,17 +1316,17 @@ BOOL LLFloaterIMSessionTab::handleKeyHere(KEY key, MASK mask )
if (KEY_RETURN == key && !isTornOff())
{
floater_container->expandConversation();
- handled = TRUE;
+ handled = true;
}
if ((KEY_UP == key) || (KEY_LEFT == key))
{
floater_container->selectNextorPreviousConversation(false);
- handled = TRUE;
+ handled = true;
}
if ((KEY_DOWN == key ) || (KEY_RIGHT == key))
{
floater_container->selectNextorPreviousConversation(true);
- handled = TRUE;
+ handled = true;
}
}
return handled;