protect against static init ordering

This commit is contained in:
David Rose 2009-04-17 21:54:20 +00:00
parent 5a74ea30dd
commit 5929192b26
1 changed files with 13 additions and 2 deletions

View File

@ -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;
}
}