summaryrefslogtreecommitdiff
path: root/indra/newview/llfloaterconversationpreview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloaterconversationpreview.cpp')
-rwxr-xr-xindra/newview/llfloaterconversationpreview.cpp43
1 files changed, 19 insertions, 24 deletions
diff --git a/indra/newview/llfloaterconversationpreview.cpp b/indra/newview/llfloaterconversationpreview.cpp
index 7cb313af33..39630320a9 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;
@@ -90,19 +91,19 @@ BOOL LLFloaterConversationPreview::postBuild()
mPageSpinner->setMinValue(1);
mPageSpinner->set(1);
mPageSpinner->setEnabled(false);
- mChatHistoryLoaded = false;
LLLogChat::startChatHistoryThread(file, load_params);
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);
@@ -119,7 +120,6 @@ void LLFloaterConversationPreview::draw()
if(mChatHistoryLoaded)
{
showHistory();
- mChatHistoryLoaded = false;
}
LLFloater::draw();
}
@@ -134,32 +134,27 @@ void LLFloaterConversationPreview::onOpen(const LLSD& key)
void LLFloaterConversationPreview::showHistory()
{
- if (!mMessages.size())
+ if (!mChatHistoryLoaded)
{
return;
}
+ mChatHistoryLoaded = false;
- mChatHistory->clear();
-
- std::ostringstream message;
- std::list<LLSD>::const_iterator iter = mMessages.begin();
-
- int delta = 0;
- if (mCurrentPage)
+ // additional protection to avoid changes of mMessages in setPages
+ LLMutexLock lock(&mMutex);
+ if(!mMessages.size() || mCurrentPage * mPageSize >= mMessages.size())
{
- int remainder = mMessages.size() % mPageSize;
- delta = (remainder == 0) ? 0 : (mPageSize - remainder);
+ return;
}
- std::advance(iter, (mCurrentPage * mPageSize) - delta);
+ mChatHistory->clear();
- for (int msg_num = 0; (iter != mMessages.end() && msg_num < mPageSize); ++iter, ++msg_num)
+ std::ostringstream message;
+ std::list<LLSD>::const_iterator iter = mMessages.begin();
+ std::advance(iter, mCurrentPage * mPageSize);
+
+ 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;