diff options
author | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-11-12 02:37:15 +0200 |
---|---|---|
committer | AndreyL ProductEngine <alihatskiy@productengine.com> | 2019-11-12 02:37:15 +0200 |
commit | 5f731d84cb5823bdc4cae5be288f2de2ffb9f5f9 (patch) | |
tree | 04ddffec7d5a004150aefd5fdbf247863e2a8926 /indra/newview/lllogchat.cpp | |
parent | 4aa9dfec746f28696a195fe81aed9b6ef0791954 (diff) | |
parent | e96d0d5e304324e6ab0c469773fb7110a65fc3f1 (diff) |
Downstream merge from 494-maint-wassail
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 |