Fix/workaround static object initialization in gflags
authorSergey Sharybin <sergey.vfx@gmail.com>
Wed, 17 Feb 2016 14:00:12 +0000 (15:00 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Wed, 17 Feb 2016 14:01:40 +0000 (15:01 +0100)
extern/gflags/src/gflags.cc

index a35bbfe66642e3afa1fc9d8ef057b3c3defb4d9e..7abe1f70da366c1dfd321cba098a3c6ccf35c0b0 100644 (file)
@@ -881,9 +881,15 @@ FlagRegistry* FlagRegistry::global_registry_ = NULL;
 Mutex FlagRegistry::global_registry_lock_(Mutex::LINKER_INITIALIZED);
 
 FlagRegistry* FlagRegistry::GlobalRegistry() {
-  MutexLock acquire_lock(&global_registry_lock_);
-  if (!global_registry_) {
-    global_registry_ = new FlagRegistry;
+  if (GetArgvSum() != 0) {
+    MutexLock acquire_lock(&global_registry_lock_);
+    if (!global_registry_) {
+      global_registry_ = new FlagRegistry;
+    }
+  } else {
+    if (!global_registry_) {
+      global_registry_ = new FlagRegistry;
+    }
   }
   return global_registry_;
 }