summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorpavelkproductengine <pavelkproductengine@lindenlab.com>2017-07-10 17:22:12 +0300
committerpavelkproductengine <pavelkproductengine@lindenlab.com>2017-07-10 17:22:12 +0300
commit530f69ff33a6b3854c489590eddb0ba7d6bd7264 (patch)
treef21c333002cfd88008f2234a0b0d836ad5cb0e1a /indra
parent5478f2a223b5b679fe4515aa5a88f9ae1ed36985 (diff)
MAINT-7541 Not able to save login credentials on clean install
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llmachineid.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/indra/newview/llmachineid.cpp b/indra/newview/llmachineid.cpp
index b5fd3df0f3..b0ee8e7fcb 100644
--- a/indra/newview/llmachineid.cpp
+++ b/indra/newview/llmachineid.cpp
@@ -37,6 +37,28 @@ using namespace std;
unsigned char static_unique_id[] = {0,0,0,0,0,0};
bool static has_static_unique_id = false;
+#if LL_WINDOWS
+
+class LLComInitialize
+{
+ HRESULT mHR;
+public:
+ LLComInitialize()
+ {
+ mHR = CoInitializeEx(0, COINIT_MULTITHREADED);
+ if (FAILED(mHR))
+ LL_DEBUGS("AppInit") << "Failed to initialize COM library. Error code = 0x" << hex << mHR << LL_ENDL;
+ }
+
+ ~LLComInitialize()
+ {
+ if (SUCCEEDED(mHR))
+ CoUninitialize();
+ }
+};
+
+#endif //LL_WINDOWS
+
// get an unique machine id.
// NOT THREAD SAFE - do before setting up threads.
// MAC Address doesn't work for Windows 7 since the first returned hardware MAC address changes with each reboot, Go figure??
@@ -59,12 +81,7 @@ S32 LLMachineID::init()
// Step 1: --------------------------------------------------
// Initialize COM. ------------------------------------------
- hres = CoInitializeEx(0, COINIT_MULTITHREADED);
- if (FAILED(hres))
- {
- LL_DEBUGS("AppInit") << "Failed to initialize COM library. Error code = 0x" << hex << hres << LL_ENDL;
- return 1; // Program has failed.
- }
+ LLComInitialize comInit;
// Step 2: --------------------------------------------------
// Set general COM security levels --------------------------
@@ -89,7 +106,6 @@ S32 LLMachineID::init()
if (FAILED(hres))
{
LL_WARNS("AppInit") << "Failed to initialize security. Error code = 0x" << hex << hres << LL_ENDL;
- CoUninitialize();
return 1; // Program has failed.
}
@@ -107,7 +123,6 @@ S32 LLMachineID::init()
if (FAILED(hres))
{
LL_WARNS("AppInit") << "Failed to create IWbemLocator object." << " Err code = 0x" << hex << hres << LL_ENDL;
- CoUninitialize();
return 1; // Program has failed.
}
@@ -134,7 +149,6 @@ S32 LLMachineID::init()
{
LL_WARNS("AppInit") << "Could not connect. Error code = 0x" << hex << hres << LL_ENDL;
pLoc->Release();
- CoUninitialize();
return 1; // Program has failed.
}
@@ -160,7 +174,6 @@ S32 LLMachineID::init()
LL_WARNS("AppInit") << "Could not set proxy blanket. Error code = 0x" << hex << hres << LL_ENDL;
pSvc->Release();
pLoc->Release();
- CoUninitialize();
return 1; // Program has failed.
}
@@ -181,7 +194,6 @@ S32 LLMachineID::init()
LL_WARNS("AppInit") << "Query for operating system name failed." << " Error code = 0x" << hex << hres << LL_ENDL;
pSvc->Release();
pLoc->Release();
- CoUninitialize();
return 1; // Program has failed.
}
@@ -236,7 +248,6 @@ S32 LLMachineID::init()
pLoc->Release();
if (pEnumerator)
pEnumerator->Release();
- CoUninitialize();
ret_code=0;
#else
unsigned char * staticPtr = (unsigned char *)(&static_unique_id[0]);