diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 9cadd70dd8f80c184f5d4fe80d1b1fac9ea640bb..463048008f256815e883e8888bdaecb43eb7fa57 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -30,7 +30,7 @@ #include "lltracethreadrecorder.h" #include "llfasttimer.h" -static bool sInitialized; +static S32 sInitializationCount = 0; namespace LLTrace { @@ -39,19 +39,24 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL; void init() { - gMasterThreadRecorder = new MasterThreadRecorder(); - sInitialized = true; + if (sInitializationCount++ == 0) + { + gMasterThreadRecorder = new MasterThreadRecorder(); + } } bool isInitialized() { - return sInitialized; + return sInitializationCount > 0; } void cleanup() { - delete gMasterThreadRecorder; - gMasterThreadRecorder = NULL; + if (--sInitializationCount == 0) + { + delete gMasterThreadRecorder; + gMasterThreadRecorder = NULL; + } } MasterThreadRecorder& getMasterThreadRecorder() diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h index 9c89b6b280fabd309041a2cb7fc1a134fac802f2..8534ed6298a1ba8742ae78cd41edf823115d17f1 100644 --- a/indra/llcommon/llwin32headers.h +++ b/indra/llcommon/llwin32headers.h @@ -28,9 +28,13 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS +#ifndef NOMINMAX +#define NOMINMAX +#endif #undef WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <windows.h> +#undef NOMINMAX #endif #endif diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h index d3fb90d4b1814c4a3624bf2d1e42aebff45dfa02..f7e71301a8f8647a471e6f34e1a41da383f94de9 100644 --- a/indra/llcommon/llwin32headerslean.h +++ b/indra/llcommon/llwin32headerslean.h @@ -28,9 +28,13 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS +#ifndef NOMINMAX +#define NOMINMAX +#endif #define WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <windows.h> +#undef NOMINMAX #endif #endif diff --git a/indra/test/io.cpp b/indra/test/io.cpp index f2b4a5339c334fb5de32a29830c5ca6298b3da68..b3eabc2e8a52873abf332ed65ccd9beded5952af 100644 --- a/indra/test/io.cpp +++ b/indra/test/io.cpp @@ -831,7 +831,6 @@ namespace tut public: PumpAndChainTestData() { - LLCommon::initClass(); apr_pool_create(&mPool, NULL); mPump = new LLPumpIO(mPool); } @@ -841,7 +840,6 @@ namespace tut mChain.clear(); delete mPump; apr_pool_destroy(mPool); - LLCommon::cleanupClass(); } }; typedef test_group<PumpAndChainTestData> PumpAndChainTestGroup; @@ -912,7 +910,6 @@ namespace tut pipe_and_pump_fitness() { - LLCommon::initClass(); LLFrameTimer::updateFrameTime(); apr_pool_create(&mPool, NULL); mPump = new LLPumpIO(mPool); @@ -927,7 +924,6 @@ namespace tut mSocket.reset(); delete mPump; apr_pool_destroy(mPool); - LLCommon::cleanupClass(); } protected: @@ -1191,11 +1187,9 @@ namespace tut LLSimpleRPCResponse(LLSD* response) : mResponsePtr(response) { - LLCommon::initClass(); } ~LLSimpleRPCResponse() { - LLCommon::cleanupClass(); } virtual bool response(LLPumpIO* pump) { diff --git a/indra/test/llhttpdate_tut.cpp b/indra/test/llhttpdate_tut.cpp index d6f0ba5e66eec564881dd99122f43ac256a8346a..ecf734ee9077eab4f4f7d7b7a3b816792292bc63 100644 --- a/indra/test/llhttpdate_tut.cpp +++ b/indra/test/llhttpdate_tut.cpp @@ -41,11 +41,9 @@ namespace tut { httpdate_data() { - LLCommon::initClass(); } ~httpdate_data() { - LLCommon::cleanupClass(); } LLDate some_date; }; diff --git a/indra/test/lliohttpserver_tut.cpp b/indra/test/lliohttpserver_tut.cpp index e7af09f80b0441ef63df22aacb3ac5b46c087d4b..3fa5c8dd423b6d1d32fd7e99d553a2a2eed993b5 100644 --- a/indra/test/lliohttpserver_tut.cpp +++ b/indra/test/lliohttpserver_tut.cpp @@ -77,7 +77,6 @@ namespace tut HTTPServiceTestData() : mResponse(NULL) { - LLCommon::initClass(); LLHTTPStandardServices::useServices(); LLHTTPRegistrar::buildAllServices(mRoot); mRoot.addNode("/delayed/echo", new DelayedEcho(this)); @@ -86,7 +85,6 @@ namespace tut ~HTTPServiceTestData() { - LLCommon::cleanupClass(); } LLHTTPNode mRoot; diff --git a/indra/test/test.cpp b/indra/test/test.cpp index 8bd302ce7a9a9eb9967bc8b9f7d7ddfb40c118bb..28de88201c2db1bfd3ee43c0a1af78028b276742 100644 --- a/indra/test/test.cpp +++ b/indra/test/test.cpp @@ -514,8 +514,8 @@ int main(int argc, char **argv) #endif ll_init_apr(); - LLTrace::init(); + LLTrace::init(); apr_getopt_t* os = NULL; if(APR_SUCCESS != apr_getopt_init(&os, gAPRPoolp, argc, argv)) { diff --git a/indra/test_apps/llplugintest/llmediaplugintest.cpp b/indra/test_apps/llplugintest/llmediaplugintest.cpp index 99a82ed555846a1ec1163c857b26efe297140df7..fa4f5abd284d8a2a683ba8aa7756c136a49c2782 100644 --- a/indra/test_apps/llplugintest/llmediaplugintest.cpp +++ b/indra/test_apps/llplugintest/llmediaplugintest.cpp @@ -41,7 +41,6 @@ #if LL_WINDOWS #pragma warning(disable: 4263) #pragma warning(disable: 4264) -#undef NOMINMAX #endif #if __APPLE__