From c21b3bbaccdad847611c5af78f612a3db2f47cc1 Mon Sep 17 00:00:00 2001
From: andreykproductengine <andreykproductengine@lindenlab.com>
Date: Fri, 25 Aug 2017 20:26:25 +0300
Subject: [PATCH] MAINT-7739 Make LLOSInfo a Singleton

---
 indra/llcommon/llsys.h             |  5 +++--
 indra/newview/llappviewer.cpp      | 23 +++++++++++++----------
 indra/newview/llappviewer.h        |  4 ----
 indra/newview/llfeaturemanager.cpp |  4 ++--
 indra/newview/llpanellogin.cpp     |  2 +-
 indra/newview/llstartup.cpp        |  2 +-
 indra/newview/llviewerstats.cpp    |  2 +-
 indra/newview/llweb.cpp            |  2 +-
 8 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h
index 962367f69fe..294d0066ca5 100644
--- a/indra/llcommon/llsys.h
+++ b/indra/llcommon/llsys.h
@@ -37,13 +37,14 @@
 //
 
 #include "llsd.h"
+#include "llsingleton.h"
 #include <iosfwd>
 #include <string>
 
-class LL_COMMON_API LLOSInfo
+class LL_COMMON_API LLOSInfo : public LLSingleton<LLOSInfo>
 {
+	LLSINGLETON(LLOSInfo);
 public:
-	LLOSInfo();
 	void stream(std::ostream& s) const;
 
 	const std::string& getOSString() const;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 958876fb0a9..51d7ad11388 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -733,7 +733,7 @@ LLAppViewer::LLAppViewer()
 	//
 	
 	LLLoginInstance::instance().setUpdaterService(mUpdater.get());
-	LLLoginInstance::instance().setPlatformInfo(gPlatform, getOSInfo().getOSVersionString());
+	LLLoginInstance::instance().setPlatformInfo(gPlatform, LLOSInfo::instance().getOSVersionString());
 }
 
 LLAppViewer::~LLAppViewer()
@@ -3110,7 +3110,7 @@ void LLAppViewer::initUpdater()
 	mUpdater->initialize(channel, 
 						 version,
 						 gPlatform,
-						 getOSInfo().getOSVersionString(),
+						 LLOSInfo::instance().getOSVersionString(),
 						 unique_id,
 						 willing_to_test
 						 );
@@ -3192,10 +3192,13 @@ bool LLAppViewer::initWindow()
 		
     
 #ifdef LL_DARWIN
-    //Satisfy both MAINT-3135 (OSX 10.6 and earlier) MAINT-3288 (OSX 10.7 and later)
-   if (getOSInfo().mMajorVer == 10 && getOSInfo().mMinorVer < 7)
-		if ( getOSInfo().mMinorVer == 6 && getOSInfo().mBuild < 8 )
-       		gViewerWindow->getWindow()->setOldResize(true);
+	//Satisfy both MAINT-3135 (OSX 10.6 and earlier) MAINT-3288 (OSX 10.7 and later)
+	LLOSInfo& os_info = LLOSInfo::instance();
+	if (os_info.mMajorVer == 10 && os_info.mMinorVer < 7)
+	{
+		if ( os_info.mMinorVer == 6 && os_info.mBuild < 8 )
+			gViewerWindow->getWindow()->setOldResize(true);
+	}
 #endif
     
 	if (gSavedSettings.getBOOL("WindowMaximized"))
@@ -3337,7 +3340,7 @@ LLSD LLAppViewer::getViewerInfo() const
 	info["CPU"] = gSysCPU.getCPUString();
 	info["MEMORY_MB"] = LLSD::Integer(gSysMemory.getPhysicalMemoryKB().valueInUnits<LLUnits::Megabytes>());
 	// Moved hack adjustment to Windows memory size into llsys.cpp
-	info["OS_VERSION"] = LLAppViewer::instance()->getOSInfo().getOSString();
+	info["OS_VERSION"] = LLOSInfo::instance().getOSString();
 	info["GRAPHICS_CARD_VENDOR"] = (const char*)(glGetString(GL_VENDOR));
 	info["GRAPHICS_CARD"] = (const char*)(glGetString(GL_RENDERER));
 
@@ -3659,7 +3662,7 @@ void LLAppViewer::writeSystemInfo()
 	
 	gDebugInfo["RAMInfo"]["Physical"] = (LLSD::Integer)(gSysMemory.getPhysicalMemoryKB().value());
 	gDebugInfo["RAMInfo"]["Allocated"] = (LLSD::Integer)(gMemoryAllocated.valueInUnits<LLUnits::Kilobytes>());
-	gDebugInfo["OSInfo"] = getOSInfo().getOSStringSimple();
+	gDebugInfo["OSInfo"] = LLOSInfo::instance().getOSStringSimple();
 
 	// The user is not logged on yet, but record the current grid choice login url
 	// which may have been the intended grid. 
@@ -3701,8 +3704,8 @@ void LLAppViewer::writeSystemInfo()
 	// query some system information
 	LL_INFOS("SystemInfo") << "CPU info:\n" << gSysCPU << LL_ENDL;
 	LL_INFOS("SystemInfo") << "Memory info:\n" << gSysMemory << LL_ENDL;
-	LL_INFOS("SystemInfo") << "OS: " << getOSInfo().getOSStringSimple() << LL_ENDL;
-	LL_INFOS("SystemInfo") << "OS info: " << getOSInfo() << LL_ENDL;
+	LL_INFOS("SystemInfo") << "OS: " << LLOSInfo::instance().getOSStringSimple() << LL_ENDL;
+	LL_INFOS("SystemInfo") << "OS info: " << LLOSInfo::instance() << LL_ENDL;
 
     gDebugInfo["SettingsFilename"] = gSavedSettings.getString("ClientSettingsFile");
 	gDebugInfo["ViewerExePath"] = gDirUtilp->getExecutablePathAndName();
diff --git a/indra/newview/llappviewer.h b/indra/newview/llappviewer.h
index c36d8cd9fd1..520ff68a027 100644
--- a/indra/newview/llappviewer.h
+++ b/indra/newview/llappviewer.h
@@ -98,8 +98,6 @@ class LLAppViewer : public LLApp
 
 	void writeDebugInfo(bool isStatic=true);
 
-	const LLOSInfo& getOSInfo() const { return mSysOSInfo; }
-
 	void setServerReleaseNotesURL(const std::string& url) { mServerReleaseNotesURL = url; }
 	LLSD getViewerInfo() const;
 	std::string getViewerInfoString() const;
@@ -270,8 +268,6 @@ class LLAppViewer : public LLApp
 	std::string mLogoutMarkerFileName;
 	LLAPRFile mLogoutMarkerFile; // A file created to indicate the app is running.
 
-	
-	LLOSInfo mSysOSInfo; 
 	bool mReportedCrash;
 
 	std::string mServerReleaseNotesURL;
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index d4ba230feb2..ae4ce298a0a 100644
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -486,7 +486,7 @@ void LLFeatureManager::fetchFeatureTableCoro(std::string tableName)
 
 
 #if LL_WINDOWS
-    std::string os_string = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
+    std::string os_string = LLOSInfo::instance().getOSStringSimple();
     std::string filename;
 
     if (os_string.find("Microsoft Windows XP") == 0)
@@ -767,7 +767,7 @@ void LLFeatureManager::applyBaseMasks()
 	}
 
 #if LL_DARWIN
-	const LLOSInfo& osInfo = LLAppViewer::instance()->getOSInfo();
+	const LLOSInfo& osInfo = LLOSInfo::instance();
 	if (osInfo.mMajorVer == 10 && osInfo.mMinorVer < 7)
 	{
 		maskFeatures("OSX_10_6_8");
diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp
index f8a5bbb036f..a88c10521c4 100644
--- a/indra/newview/llpanellogin.cpp
+++ b/indra/newview/llpanellogin.cpp
@@ -791,7 +791,7 @@ void LLPanelLogin::loadLoginPage()
 	params["grid"] = LLGridManager::getInstance()->getGridId();
 
 	// add OS info
-	params["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
+	params["os"] = LLOSInfo::instance().getOSStringSimple();
 
 	// sourceid
 	params["sourceid"] = gSavedSettings.getString("sourceid");
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index fcde03244ae..8295ce029bf 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -345,7 +345,7 @@ bool idle_startup()
 	const std::string delims (" ");
 	std::string system;
 	int begIdx, endIdx;
-	std::string osString = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
+	std::string osString = LLOSInfo::instance().getOSStringSimple();
 
 	begIdx = osString.find_first_not_of (delims);
 	endIdx = osString.find_first_of (delims, begIdx);
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index dd44697dcd4..7f88d5e30f5 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -489,7 +489,7 @@ void send_stats()
 	LLSD &system = body["system"];
 	
 	system["ram"] = (S32) gSysMemory.getPhysicalMemoryKB().value();
-	system["os"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
+	system["os"] = LLOSInfo::instance().getOSStringSimple();
 	system["cpu"] = gSysCPU.getCPUString();
 	unsigned char MACAddress[MAC_ADDRESS_BYTES];
 	LLUUID::getNodeID(MACAddress);
diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp
index ec82765b962..b816225b072 100644
--- a/indra/newview/llweb.cpp
+++ b/indra/newview/llweb.cpp
@@ -192,7 +192,7 @@ std::string LLWeb::expandURLSubstitutions(const std::string &url,
 	substitution["CHANNEL"] = LLVersionInfo::getChannel();
 	substitution["GRID"] = LLGridManager::getInstance()->getGridId();
 	substitution["GRID_LOWERCASE"] = utf8str_tolower(LLGridManager::getInstance()->getGridId());
-	substitution["OS"] = LLAppViewer::instance()->getOSInfo().getOSStringSimple();
+	substitution["OS"] = LLOSInfo::instance().getOSStringSimple();
 	substitution["SESSION_ID"] = gAgent.getSessionID();
 	substitution["FIRST_LOGIN"] = gAgent.isFirstLogin();
 
-- 
GitLab