From 5929192b2645bf5f553010e8bc1aa8f98e0dd117 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 17 Apr 2009 21:54:20 +0000 Subject: [PATCH] protect against static init ordering --- panda/src/putil/loaderOptions.cxx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/panda/src/putil/loaderOptions.cxx b/panda/src/putil/loaderOptions.cxx index 1c5230e0fc..272950200d 100644 --- a/panda/src/putil/loaderOptions.cxx +++ b/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; } }