MAINT-3117 FIXED crash in LLFloaterConversationPreview::showHistory()
Updated fix with a more complex and stable version. Integrated solution from the CHUI-836.master
parent
6198219d9d
commit
d995782edf
|
|
@ -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,7 +134,15 @@ void LLFloaterConversationPreview::onOpen(const LLSD& key)
|
|||
|
||||
void LLFloaterConversationPreview::showHistory()
|
||||
{
|
||||
if (!mMessages.size())
|
||||
if (!mChatHistoryLoaded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mChatHistoryLoaded = false;
|
||||
|
||||
// additional protection to avoid changes of mMessages in setPages
|
||||
LLMutexLock lock(&mMutex);
|
||||
if(!mMessages.size() || mCurrentPage * mPageSize >= mMessages.size())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
@ -143,23 +151,10 @@ void LLFloaterConversationPreview::showHistory()
|
|||
|
||||
std::ostringstream message;
|
||||
std::list<LLSD>::const_iterator iter = mMessages.begin();
|
||||
|
||||
int delta = 0;
|
||||
if (mCurrentPage)
|
||||
std::advance(iter, mCurrentPage * mPageSize);
|
||||
|
||||
for (int msg_num = 0; iter != mMessages.end() && msg_num < mPageSize; ++iter, ++msg_num)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (iter->size() == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
LLSD msg = *iter;
|
||||
|
||||
LLUUID from_id = LLUUID::null;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue