summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterconversationpreview.cpp
diff options
context:
space:
mode:
authorOz Linden <oz@lindenlab.com>2013-10-23 13:05:59 -0400
committerOz Linden <oz@lindenlab.com>2013-10-23 13:05:59 -0400
commitc9775dde6249582f0e8976be15e72bfebc4ac3fc (patch)
tree83407157dae234db649dfff763e68f6e3c843335 /indra/newview/llfloaterconversationpreview.cpp
parent1a72325ef1e8c798066d8ef7f82acd08d60fb68c (diff)
parentea1e1b0925b386cf83178539b8eae9e25c573548 (diff)
merge up to 3.6.9-release
Diffstat (limited to 'indra/newview/llfloaterconversationpreview.cpp')
-rwxr-xr-xindra/newview/llfloaterconversationpreview.cpp44
1 files changed, 18 insertions, 26 deletions
diff --git a/indra/newview/llfloaterconversationpreview.cpp b/indra/newview/llfloaterconversationpreview.cpp
index b570de14aa..4a85160f95 100755
--- a/indra/newview/llfloaterconversationpreview.cpp
+++ b/indra/newview/llfloaterconversationpreview.cpp
@@ -43,14 +43,15 @@ LLFloaterConversationPreview::LLFloaterConversationPreview(const LLSD& session_i
mCurrentPage(0),
mPageSize(gSavedSettings.getS32("ConversationHistoryPageSize")),
mAccountName(session_id[LL_FCP_ACCOUNT_NAME]),
- mCompleteName(session_id[LL_FCP_COMPLETE_NAME])
+ mCompleteName(session_id[LL_FCP_COMPLETE_NAME]),
+ mMutex(NULL)
{
}
BOOL LLFloaterConversationPreview::postBuild()
{
mChatHistory = getChild<LLChatHistory>("chat_history");
- LLLoadHistoryThread::setLoadEndSignal(boost::bind(&LLFloaterConversationPreview::SetPages, this, _1, _2));
+ LLLoadHistoryThread::setLoadEndSignal(boost::bind(&LLFloaterConversationPreview::setPages, this, _1, _2));
const LLConversation* conv = LLConversationLog::instance().getConversation(mSessionID);
std::string name;
@@ -95,14 +96,15 @@ BOOL LLFloaterConversationPreview::postBuild()
return LLFloater::postBuild();
}
-void LLFloaterConversationPreview::SetPages(std::list<LLSD>& messages, const std::string& file_name)
+void LLFloaterConversationPreview::setPages(std::list<LLSD>& messages,const std::string& file_name)
{
if(file_name == mChatHistoryFileName)
{
+ // additional protection to avoid changes of mMessages in setPages()
+ LLMutexLock lock(&mMutex);
mMessages = messages;
+ mCurrentPage = (mMessages.size() ? (mMessages.size() - 1) / mPageSize : 0);
-
- mCurrentPage = mMessages.size() / mPageSize;
mPageSpinner->setEnabled(true);
mPageSpinner->setMaxValue(mCurrentPage+1);
mPageSpinner->set(mCurrentPage+1);
@@ -110,10 +112,9 @@ void LLFloaterConversationPreview::SetPages(std::list<LLSD>& messages, const std
std::string total_page_num = llformat("/ %d", mCurrentPage+1);
getChild<LLTextBox>("page_num_label")->setValue(total_page_num);
mChatHistoryLoaded = true;
-
}
-
}
+
void LLFloaterConversationPreview::draw()
{
if(mChatHistoryLoaded)
@@ -126,37 +127,29 @@ void LLFloaterConversationPreview::draw()
void LLFloaterConversationPreview::onOpen(const LLSD& key)
{
- showHistory();
+ if(mChatHistoryLoaded)
+ {
+ showHistory();
+ }
}
void LLFloaterConversationPreview::showHistory()
{
- if (!mMessages.size())
+ // additional protection to avoid changes of mMessages in setPages()
+ LLMutexLock lock(&mMutex);
+
+ if (!mMessages.size() || mCurrentPage * mPageSize >= mMessages.size())
{
return;
}
mChatHistory->clear();
-
std::ostringstream message;
std::list<LLSD>::const_iterator iter = mMessages.begin();
+ std::advance(iter, mCurrentPage * mPageSize);
- int delta = 0;
- if (mCurrentPage)
- {
- int remainder = mMessages.size() % mPageSize;
- delta = (remainder == 0) ? 0 : (mPageSize - remainder);
- }
-
- std::advance(iter, (mCurrentPage * mPageSize) - delta);
-
- for (int msg_num = 0; (iter != mMessages.end() && msg_num < mPageSize); ++iter, ++msg_num)
+ for (int msg_num = 0; iter != mMessages.end() && msg_num < mPageSize; ++iter, ++msg_num)
{
- if (iter->size() == 0)
- {
- continue;
- }
-
LLSD msg = *iter;
LLUUID from_id = LLUUID::null;
@@ -200,7 +193,6 @@ void LLFloaterConversationPreview::showHistory()
mChatHistory->appendMessage(chat,chat_args);
}
-
}
void LLFloaterConversationPreview::onMoreHistoryBtnClick()