Browse Source

fix static init loop

David Rose 17 years ago
parent
commit
d7ec4a0fce
2 changed files with 10 additions and 4 deletions
  1. 5 2
      panda/src/pgraph/modelPool.cxx
  2. 5 2
      panda/src/text/fontPool.cxx

+ 5 - 2
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()) {

+ 5 - 2
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.