From d7ec4a0fce5054bdc20affdb5dc1bafc2240a9a8 Mon Sep 17 00:00:00 2001 From: David Rose Date: Fri, 19 Sep 2008 19:20:37 +0000 Subject: [PATCH] fix static init loop --- panda/src/pgraph/modelPool.cxx | 7 +++++-- panda/src/text/fontPool.cxx | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/panda/src/pgraph/modelPool.cxx b/panda/src/pgraph/modelPool.cxx index b47c2e12ca..4471dcba0b 100644 --- a/panda/src/pgraph/modelPool.cxx +++ b/panda/src/pgraph/modelPool.cxx @@ -20,7 +20,7 @@ ModelPool *ModelPool::_global_ptr = (ModelPool *)NULL; -static Loader model_loader; +static Loader *model_loader = NULL; //////////////////////////////////////////////////////////////////// // Function: ModelPool::write @@ -73,7 +73,10 @@ ns_load_model(const string &filename, const LoaderOptions &options) { new_options.set_flags((new_options.get_flags() | LoaderOptions::LF_no_ram_cache) & ~(LoaderOptions::LF_search | LoaderOptions::LF_report_errors)); - PT(PandaNode) panda_node = model_loader.load_sync(filename, new_options); + if (model_loader == (Loader *)NULL) { + model_loader = new Loader("ModelPool", 0); + } + PT(PandaNode) panda_node = model_loader->load_sync(filename, new_options); PT(ModelRoot) node; if (panda_node.is_null()) { diff --git a/panda/src/text/fontPool.cxx b/panda/src/text/fontPool.cxx index ebd93cad9a..a833456086 100644 --- a/panda/src/text/fontPool.cxx +++ b/panda/src/text/fontPool.cxx @@ -24,7 +24,7 @@ FontPool *FontPool::_global_ptr = (FontPool *)NULL; -static Loader model_loader; +static Loader *model_loader = NULL; //////////////////////////////////////////////////////////////////// // Function: FontPool::write @@ -94,7 +94,10 @@ ns_load_font(const string &str) { string extension = filename.get_extension(); if (extension.empty() || extension == "egg" || extension == "bam") { - PT(PandaNode) node = model_loader.load_sync(filename); + if (model_loader == (Loader *)NULL) { + model_loader = new Loader("FontPool", 0); + } + PT(PandaNode) node = model_loader->load_sync(filename); if (node != (PandaNode *)NULL) { // It is a model. Elevate all the priorities by 1, and make a // font out of it.