summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rwxr-xr-xindra/newview/llfloaterconversationpreview.cpp43
-rwxr-xr-xindra/newview/llfloaterconversationpreview.h3
2 files changed, 21 insertions, 25 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;
diff --git a/indra/newview/llfloaterconversationpreview.h b/indra/newview/llfloaterconversationpreview.h
index 389f3dfd09..f8796127ba 100755
--- a/indra/newview/llfloaterconversationpreview.h
+++ b/indra/newview/llfloaterconversationpreview.h
@@ -42,7 +42,7 @@ public:
virtual ~LLFloaterConversationPreview(){};
virtual BOOL postBuild();
- void SetPages(std::list<LLSD>& messages,const std::string& file_name);
+ void setPages(std::list<LLSD>& messages,const std::string& file_name);
virtual void draw();
virtual void onOpen(const LLSD& key);
@@ -51,6 +51,7 @@ private:
void onMoreHistoryBtnClick();
void showHistory();
+ LLMutex mMutex;
LLSpinCtrl* mPageSpinner;
LLChatHistory* mChatHistory;
LLUUID mSessionID;