From 6198219d9da6e069804d57ca9a3e711341a4c2e0 Mon Sep 17 00:00:00 2001 From: dmitrykproductengine Date: Mon, 9 Sep 2013 21:19:44 +0300 Subject: MAINT-3117 FIXED crash in LLFloaterConversationPreview::showHistory() --- indra/newview/llfloaterconversationpreview.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'indra/newview/llfloaterconversationpreview.cpp') diff --git a/indra/newview/llfloaterconversationpreview.cpp b/indra/newview/llfloaterconversationpreview.cpp index b570de14aa..7cb313af33 100755 --- a/indra/newview/llfloaterconversationpreview.cpp +++ b/indra/newview/llfloaterconversationpreview.cpp @@ -126,7 +126,10 @@ void LLFloaterConversationPreview::draw() void LLFloaterConversationPreview::onOpen(const LLSD& key) { - showHistory(); + if(mChatHistoryLoaded) + { + showHistory(); + } } void LLFloaterConversationPreview::showHistory() -- cgit v1.2.3 From d995782edf1a55c327ad3f3349bd9d4b6ec3d9e6 Mon Sep 17 00:00:00 2001 From: dmitrykproductengine Date: Tue, 10 Sep 2013 10:34:20 +0300 Subject: MAINT-3117 FIXED crash in LLFloaterConversationPreview::showHistory() Updated fix with a more complex and stable version. Integrated solution from the CHUI-836. --- indra/newview/llfloaterconversationpreview.cpp | 43 ++++++++++++-------------- 1 file changed, 19 insertions(+), 24 deletions(-) (limited to 'indra/newview/llfloaterconversationpreview.cpp') 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("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& messages, const std::string& file_name) +void LLFloaterConversationPreview::setPages(std::list& 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::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::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; -- cgit v1.2.3 From 60b20e3bd899198771b3c1b255be042864618cad Mon Sep 17 00:00:00 2001 From: maksymsproductengine Date: Tue, 10 Sep 2013 22:12:11 +0300 Subject: MAINT-3117 FIXED crash in LLFloaterConversationPreview::showHistory() - optimization --- indra/newview/llfloaterconversationpreview.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'indra/newview/llfloaterconversationpreview.cpp') diff --git a/indra/newview/llfloaterconversationpreview.cpp b/indra/newview/llfloaterconversationpreview.cpp index dd8bea01b4..5041f4689d 100755 --- a/indra/newview/llfloaterconversationpreview.cpp +++ b/indra/newview/llfloaterconversationpreview.cpp @@ -44,7 +44,8 @@ LLFloaterConversationPreview::LLFloaterConversationPreview(const LLSD& session_i mPageSize(gSavedSettings.getS32("ConversationHistoryPageSize")), mAccountName(session_id[LL_FCP_ACCOUNT_NAME]), mCompleteName(session_id[LL_FCP_COMPLETE_NAME]), - mMutex(NULL) + mMutex(NULL), + mShowHistory(false) { } @@ -110,35 +111,27 @@ void LLFloaterConversationPreview::setPages(std::list& messages, const std std::string total_page_num = llformat("/ %d", mCurrentPage+1); getChild("page_num_label")->setValue(total_page_num); - mChatHistoryLoaded = true; + mShowHistory = true; } } void LLFloaterConversationPreview::draw() { - if(mChatHistoryLoaded) + if(mShowHistory) { showHistory(); + mShowHistory = false; } LLFloater::draw(); } void LLFloaterConversationPreview::onOpen(const LLSD& key) { - if(mChatHistoryLoaded) - { - showHistory(); - } + mShowHistory = true; } void LLFloaterConversationPreview::showHistory() { - if (!mChatHistoryLoaded) - { - return; - } - mChatHistoryLoaded = false; - // additional protection to avoid changes of mMessages in setPages LLMutexLock lock(&mMutex); if(!mMessages.size() || mCurrentPage * mPageSize >= mMessages.size()) @@ -201,10 +194,11 @@ void LLFloaterConversationPreview::showHistory() void LLFloaterConversationPreview::onMoreHistoryBtnClick() { mCurrentPage = (int)(mPageSpinner->getValueF32()); - if (--mCurrentPage < 0) + if (!mCurrentPage) { return; } - showHistory(); + mCurrentPage--; + mShowHistory = true; } -- cgit v1.2.3