Browse Source

protect against static init ordering

David Rose 16 years ago
parent
commit
5929192b26
1 changed files with 13 additions and 2 deletions
  1. 13 2
      panda/src/putil/loaderOptions.cxx

+ 13 - 2
panda/src/putil/loaderOptions.cxx

@@ -25,10 +25,21 @@ LoaderOptions::
 LoaderOptions(int flags) : 
   _flags(flags), _texture_flags(0)  
 {
-  if (preload_textures) {
+  // Shadowing the variables in config_util for static init ordering
+  // issues.
+  static ConfigVariableBool *preload_textures;
+  static ConfigVariableBool *preload_simple_textures;
+  if (preload_textures == NULL) {
+    preload_textures = new ConfigVariableBool("preload-textures", true);
+  }
+  if (preload_simple_textures == NULL) {
+    preload_simple_textures = new ConfigVariableBool("preload-simple-textures", false);
+  }
+
+  if (*preload_textures) {
     _texture_flags |= TF_preload;
   }
-  if (preload_simple_textures) {
+  if (*preload_simple_textures) {
     _texture_flags |= TF_preload_simple;
   }
 }