From bd42fd13b038dea5bddf06ed8da7b51d08b38bae Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Mon, 14 Oct 2019 20:49:16 +0300
Subject: [PATCH] SL-11719 Fixed init of conversation log

---
 indra/newview/llconversationlog.cpp | 24 ++++++++++++++----------
 indra/newview/llconversationlog.h   |  8 +++++++-
 indra/newview/llstartup.cpp         | 12 ++++++------
 3 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/indra/newview/llconversationlog.cpp b/indra/newview/llconversationlog.cpp
index 9ccf9b98f73..f7c61efce07 100644
--- a/indra/newview/llconversationlog.cpp
+++ b/indra/newview/llconversationlog.cpp
@@ -189,16 +189,6 @@ LLConversationLog::LLConversationLog() :
 	mAvatarNameCacheConnection(),
 	mLoggingEnabled(false)
 {
-	if(gSavedPerAccountSettings.controlExists("KeepConversationLogTranscripts"))
-	{
-		LLControlVariable * keep_log_ctrlp = gSavedPerAccountSettings.getControl("KeepConversationLogTranscripts").get();
-		S32 log_mode = keep_log_ctrlp->getValue();
-		keep_log_ctrlp->getSignal()->connect(boost::bind(&LLConversationLog::enableLogging, this, _2));
-		if (log_mode > 0)
-		{
-			enableLogging(log_mode);
-		}
-	}
 }
 
 void LLConversationLog::enableLogging(S32 log_mode)
@@ -443,6 +433,20 @@ bool LLConversationLog::moveLog(const std::string &originDirectory, const std::s
 	return true;
 }
 
+void LLConversationLog::initLoggingState()
+{
+    if (gSavedPerAccountSettings.controlExists("KeepConversationLogTranscripts"))
+    {
+        LLControlVariable * keep_log_ctrlp = gSavedPerAccountSettings.getControl("KeepConversationLogTranscripts").get();
+        S32 log_mode = keep_log_ctrlp->getValue();
+        keep_log_ctrlp->getSignal()->connect(boost::bind(&LLConversationLog::enableLogging, this, _2));
+        if (log_mode > 0)
+        {
+            enableLogging(log_mode);
+        }
+    }
+}
+
 std::string LLConversationLog::getFileName()
 {
 	std::string filename = "conversation";
diff --git a/indra/newview/llconversationlog.h b/indra/newview/llconversationlog.h
index f241276abb4..46e46a3278b 100644
--- a/indra/newview/llconversationlog.h
+++ b/indra/newview/llconversationlog.h
@@ -107,7 +107,7 @@ class LLConversation
  * To distinguish two conversations with the same sessionID it's also needed to compare their creation date.
  */
 
-class LLConversationLog : public LLParamSingleton<LLConversationLog>, LLIMSessionObserver
+class LLConversationLog : public LLSingleton<LLConversationLog>, LLIMSessionObserver
 {
 	LLSINGLETON(LLConversationLog);
 public:
@@ -147,6 +147,12 @@ class LLConversationLog : public LLParamSingleton<LLConversationLog>, LLIMSessio
 	bool getIsLoggingEnabled() { return mLoggingEnabled; }
 	bool isLogEmpty() { return mConversations.empty(); }
 
+	/**
+	 * inits connection to per account settings,
+	 * loads saved file and inits enabled state
+	 */
+	void initLoggingState();
+
 	/**
 	 * constructs file name in which conversations log will be saved
 	 * file name is conversation.log
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 6cbd83d6567..a861def7046 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -942,12 +942,6 @@ bool idle_startup()
 		LLFile::mkdir(gDirUtilp->getChatLogsDir());
 		LLFile::mkdir(gDirUtilp->getPerAccountChatLogsDir());
 
-		//Initialize conversation log only when chat log directories are ready
-		if (!LLConversationLog::instanceExists())
-		{
-			// Check existance since this part can be reached twice if login fails
-			LLConversationLog::initParamSingleton();
-		}
 
 		//good a place as any to create user windlight directories
 		std::string user_windlight_path_name(gDirUtilp->getExpandedFilename( LL_PATH_USER_SETTINGS , "windlight", ""));
@@ -1298,6 +1292,12 @@ bool idle_startup()
 		LLStartUp::initExperiences();
 
 		display_startup();
+
+		// If logging should be enebled, turns it on and loads history from disk
+		// Note: does not happen on init of singleton because preferences can use
+		// this instance without logging in
+		LLConversationLog::getInstance()->initLoggingState();
+
 		LLStartUp::setStartupState( STATE_MULTIMEDIA_INIT );
 
 		return FALSE;
-- 
GitLab