diff options
author | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-11-12 04:24:35 +0200 |
---|---|---|
committer | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-11-12 04:24:35 +0200 |
commit | 91fa31c065a582b9ead8a3d2f537c9b3d72474ee (patch) | |
tree | 50a83e42321a2b611df7c8e3f72ef452f868c591 /indra/newview/lllogchat.cpp | |
parent | 2d69438ee37a2224698418c2d00b19015b70b2b5 (diff) | |
parent | f13cc44f8999a9897c77411d1296582b7bc1f08d (diff) |
Downstream merge from lindenlab/viewer-serval
Diffstat (limited to 'indra/newview/lllogchat.cpp')
-rw-r--r-- | indra/newview/lllogchat.cpp | 94 |
1 files changed, 50 insertions, 44 deletions
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp index e2f253d2bd..0c64531783 100644 --- a/indra/newview/lllogchat.cpp +++ b/indra/newview/lllogchat.cpp @@ -211,11 +211,24 @@ LLLogChatTimeScanner::LLLogChatTimeScanner() mTimeStream.imbue(std::locale(mTimeStream.getloc(), new time_input_facet(DATE_FORMAT))); } -LLLogChat::save_history_signal_t * LLLogChat::sSaveHistorySignal = NULL; +LLLogChat::LLLogChat() +: mSaveHistorySignal(NULL) // only needed in preferences +{ + mHistoryThreadsMutex = new LLMutex(); +} -std::map<LLUUID,LLLoadHistoryThread *> LLLogChat::sLoadHistoryThreads; -std::map<LLUUID,LLDeleteHistoryThread *> LLLogChat::sDeleteHistoryThreads; -LLMutex* LLLogChat::sHistoryThreadsMutex = NULL; +LLLogChat::~LLLogChat() +{ + delete mHistoryThreadsMutex; + mHistoryThreadsMutex = NULL; + + if (mSaveHistorySignal) + { + mSaveHistorySignal->disconnect_all_slots(); + delete mSaveHistorySignal; + mSaveHistorySignal = NULL; + } +} //static @@ -340,10 +353,7 @@ void LLLogChat::saveHistory(const std::string& filename, file.close(); - if (NULL != sSaveHistorySignal) - { - (*sSaveHistorySignal)(); - } + LLLogChat::getInstance()->triggerHistorySignal(); } // static @@ -433,13 +443,12 @@ void LLLogChat::loadChatHistory(const std::string& file_name, std::list<LLSD>& m fclose(fptr); } -// static bool LLLogChat::historyThreadsFinished(LLUUID session_id) { LLMutexLock lock(historyThreadsMutex()); bool finished = true; - std::map<LLUUID,LLLoadHistoryThread *>::iterator it = sLoadHistoryThreads.find(session_id); - if (it != sLoadHistoryThreads.end()) + std::map<LLUUID,LLLoadHistoryThread *>::iterator it = mLoadHistoryThreads.find(session_id); + if (it != mLoadHistoryThreads.end()) { finished = it->second->isFinished(); } @@ -447,95 +456,93 @@ bool LLLogChat::historyThreadsFinished(LLUUID session_id) { return false; } - std::map<LLUUID,LLDeleteHistoryThread *>::iterator dit = sDeleteHistoryThreads.find(session_id); - if (dit != sDeleteHistoryThreads.end()) + std::map<LLUUID,LLDeleteHistoryThread *>::iterator dit = mDeleteHistoryThreads.find(session_id); + if (dit != mDeleteHistoryThreads.end()) { finished = finished && dit->second->isFinished(); } return finished; } -// static LLLoadHistoryThread* LLLogChat::getLoadHistoryThread(LLUUID session_id) { LLMutexLock lock(historyThreadsMutex()); - std::map<LLUUID,LLLoadHistoryThread *>::iterator it = sLoadHistoryThreads.find(session_id); - if (it != sLoadHistoryThreads.end()) + std::map<LLUUID,LLLoadHistoryThread *>::iterator it = mLoadHistoryThreads.find(session_id); + if (it != mLoadHistoryThreads.end()) { return it->second; } return NULL; } -// static LLDeleteHistoryThread* LLLogChat::getDeleteHistoryThread(LLUUID session_id) { LLMutexLock lock(historyThreadsMutex()); - std::map<LLUUID,LLDeleteHistoryThread *>::iterator it = sDeleteHistoryThreads.find(session_id); - if (it != sDeleteHistoryThreads.end()) + std::map<LLUUID,LLDeleteHistoryThread *>::iterator it = mDeleteHistoryThreads.find(session_id); + if (it != mDeleteHistoryThreads.end()) { return it->second; } return NULL; } -// static bool LLLogChat::addLoadHistoryThread(LLUUID& session_id, LLLoadHistoryThread* lthread) { LLMutexLock lock(historyThreadsMutex()); - std::map<LLUUID,LLLoadHistoryThread *>::const_iterator it = sLoadHistoryThreads.find(session_id); - if (it != sLoadHistoryThreads.end()) + std::map<LLUUID,LLLoadHistoryThread *>::const_iterator it = mLoadHistoryThreads.find(session_id); + if (it != mLoadHistoryThreads.end()) { return false; } - sLoadHistoryThreads[session_id] = lthread; + mLoadHistoryThreads[session_id] = lthread; return true; } -// static bool LLLogChat::addDeleteHistoryThread(LLUUID& session_id, LLDeleteHistoryThread* dthread) { LLMutexLock lock(historyThreadsMutex()); - std::map<LLUUID,LLDeleteHistoryThread *>::const_iterator it = sDeleteHistoryThreads.find(session_id); - if (it != sDeleteHistoryThreads.end()) + std::map<LLUUID,LLDeleteHistoryThread *>::const_iterator it = mDeleteHistoryThreads.find(session_id); + if (it != mDeleteHistoryThreads.end()) { return false; } - sDeleteHistoryThreads[session_id] = dthread; + mDeleteHistoryThreads[session_id] = dthread; return true; } -// static void LLLogChat::cleanupHistoryThreads() { LLMutexLock lock(historyThreadsMutex()); std::vector<LLUUID> uuids; - std::map<LLUUID,LLLoadHistoryThread *>::iterator lit = sLoadHistoryThreads.begin(); - for (; lit != sLoadHistoryThreads.end(); lit++) + std::map<LLUUID,LLLoadHistoryThread *>::iterator lit = mLoadHistoryThreads.begin(); + for (; lit != mLoadHistoryThreads.end(); lit++) { - if (lit->second->isFinished() && sDeleteHistoryThreads[lit->first]->isFinished()) + if (lit->second->isFinished() && mDeleteHistoryThreads[lit->first]->isFinished()) { delete lit->second; - delete sDeleteHistoryThreads[lit->first]; + delete mDeleteHistoryThreads[lit->first]; uuids.push_back(lit->first); } } std::vector<LLUUID>::iterator uuid_it = uuids.begin(); for ( ;uuid_it != uuids.end(); uuid_it++) { - sLoadHistoryThreads.erase(*uuid_it); - sDeleteHistoryThreads.erase(*uuid_it); + mLoadHistoryThreads.erase(*uuid_it); + mDeleteHistoryThreads.erase(*uuid_it); } } -//static LLMutex* LLLogChat::historyThreadsMutex() { - if (sHistoryThreadsMutex == NULL) - { - sHistoryThreadsMutex = new LLMutex(); - } - return sHistoryThreadsMutex; + return mHistoryThreadsMutex; +} + +void LLLogChat::triggerHistorySignal() +{ + if (NULL != mSaveHistorySignal) + { + (*mSaveHistorySignal)(); + } } // static @@ -613,15 +620,14 @@ void LLLogChat::getListOfTranscriptBackupFiles(std::vector<std::string>& list_of findTranscriptFiles(pattern, list_of_transcriptions); } -//static boost::signals2::connection LLLogChat::setSaveHistorySignal(const save_history_signal_t::slot_type& cb) { - if (NULL == sSaveHistorySignal) + if (NULL == mSaveHistorySignal) { - sSaveHistorySignal = new save_history_signal_t(); + mSaveHistorySignal = new save_history_signal_t(); } - return sSaveHistorySignal->connect(cb); + return mSaveHistorySignal->connect(cb); } //static |