diff --git a/src/common/time.cpp b/src/common/time.cpp index b60bf2e6c4..7dfe4ac080 100644 --- a/src/common/time.cpp +++ b/src/common/time.cpp @@ -161,9 +161,10 @@ int wxGetTimeZone() ftime(&tb); return tb.timezone*60; #elif defined(__VISUALC__) - // We must initialize the time zone information before using it (this will - // be done only once internally). - _tzset(); + // We must initialize the time zone information before using it. It's not a + // problem if we do it twice due to a race condition, as it's idempotent + // anyhow, so don't bother with any locks here. + static bool s_tzSet = (_tzset(), true); // Starting with VC++ 8 timezone variable is deprecated and is not even // available in some standard library version so use the new function for @@ -177,7 +178,7 @@ int wxGetTimeZone() #endif #else // Use some kind of time zone variable. // In any case we must initialize the time zone before using it. - tzset(); + static bool s_tzSet = (tzset(), true); #if defined(WX_TIMEZONE) // If WX_TIMEZONE was defined by configure, use it. return WX_TIMEZONE;