summaryrefslogtreecommitdiff
path: root/indra/newview/lllogchat.cpp
diff options
context:
space:
mode:
authorAndreyL ProductEngine <alihatskiy@productengine.com>2019-11-13 10:50:25 +0200
committerAndreyL ProductEngine <alihatskiy@productengine.com>2019-11-13 10:50:25 +0200
commitf83ada32f728740254668792f9d77b5745d80d2e (patch)
tree593a31ab109e1e8b088d0c2a5536e73cb6b9a050 /indra/newview/lllogchat.cpp
parentb1ac8092eecf5fc9dc4b4867370a51e5dfba4331 (diff)
parent78bdf57ad6610b34389226bf941ba736ca0c2225 (diff)
Merged in lindenlab/viewer-release
Diffstat (limited to 'indra/newview/lllogchat.cpp')
-rw-r--r--indra/newview/lllogchat.cpp94
1 files changed, 50 insertions, 44 deletions
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index 1bdeddbcfe..453bf17b11 100644
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -209,11 +209,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
@@ -338,10 +351,7 @@ void LLLogChat::saveHistory(const std::string& filename,
file.close();
- if (NULL != sSaveHistorySignal)
- {
- (*sSaveHistorySignal)();
- }
+ LLLogChat::getInstance()->triggerHistorySignal();
}
// static
@@ -416,13 +426,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();
}
@@ -430,95 +439,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
@@ -596,15 +603,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