Index: /OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp
===================================================================
--- /OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp (revision 9736)
+++ /OpenSceneGraph/trunk/src/osgDB/DatabasePager.cpp (revision 10054)
@@ -112,5 +112,5 @@
 {
 public:
-    FindCompileableGLObjectsVisitor(DatabasePager::DataToCompile& dataToCompile, 
+    FindCompileableGLObjectsVisitor(DatabasePager::DataToCompile* dataToCompile,
                                bool changeAutoUnRef, bool valueAutoUnRef,
                                bool changeAnisotropy, float valueAnisotropy,
@@ -128,9 +128,8 @@
             _kdTreeBuilder = osgDB::Registry::instance()->getKdTreeBuilder()->clone();
         }
-        
-    }
-    
+    }
+
     META_NodeVisitor("osgDB","FindCompileableGLObjectsVisitor")
-    
+
     virtual void apply(osg::Node& node)
     {
@@ -139,9 +138,9 @@
         traverse(node);
     }
-    
+
     virtual void apply(osg::Geode& geode)
     {
         apply(geode.getStateSet());
-    
+
         for(unsigned int i=0;i<geode.getNumDrawables();++i)
         {
@@ -150,12 +149,11 @@
 
         traverse(geode);
-        
+
         if (_kdTreeBuilder.valid())
         {
             geode.accept(*_kdTreeBuilder);
         }
-        
-    }
-    
+    }
+
     inline void apply(osg::StateSet* stateset)
     {
@@ -182,5 +180,5 @@
                             texture->setMaxAnisotropy(_valueAnisotropy);
                     }
-                    
+
                     if (!_pager->isCompiled(texture))
                     {
@@ -198,12 +196,12 @@
                 }
             }
-            if (compileStateSet)
-            {
-                _dataToCompile.first.insert(stateset);
-            }
-
-        }
-    }
-    
+            if (compileStateSet && _dataToCompile)
+            {
+                _dataToCompile->first.insert(stateset);
+            }
+
+        }
+    }
+
     inline void apply(osg::Drawable* drawable)
     {
@@ -212,7 +210,7 @@
 
         _drawableSet.insert(drawable);
-        
+
         apply(drawable->getStateSet());
-        
+
         switch(_drawablePolicy)
         {
@@ -241,12 +239,12 @@
         // XXX This "compiles" VBOs too, but compilation doesn't do
         // anything for VBOs, does it?
-        if (drawable->getUseDisplayList() && !_pager->isCompiled(drawable))
+        if (_dataToCompile && drawable->getUseDisplayList() && !_pager->isCompiled(drawable))
         {
             // osg::notify(osg::NOTICE)<<"  Found compilable drawable"<<std::endl;
-            _dataToCompile.second.push_back(drawable);
-        }
-    }
-    
-    DatabasePager::DataToCompile&           _dataToCompile;
+            _dataToCompile->second.push_back(drawable);
+        }
+    }
+    
+    DatabasePager::DataToCompile*           _dataToCompile;
     bool                                    _changeAutoUnRef;
     bool                                    _valueAutoUnRef;
@@ -596,6 +594,10 @@
                 ActiveGraphicsContexts::iterator itr = _pager->_activeGraphicsContexts.begin();
 
-                DataToCompile& dtc = databaseRequest->_dataToCompileMap[*itr];
-                ++itr;                
+                DataToCompile* dtc = 0;
+                if (itr != _pager->_activeGraphicsContexts.end())
+                {
+                    dtc = &(databaseRequest->_dataToCompileMap[*itr]);
+                    ++itr;
+                }
 
                 // find all the compileable rendering objects
@@ -620,5 +622,5 @@
                     !_pager->_activeGraphicsContexts.empty())
                 {
-                    if (!dtc.first.empty() || !dtc.second.empty())
+                    if (!dtc->first.empty() || !dtc->second.empty())
                     {
                         loadedObjectsNeedToBeCompiled = true;                
@@ -629,5 +631,5 @@
                             ++itr)
                         {
-                            databaseRequest->_dataToCompileMap[*itr] = dtc;
+                            databaseRequest->_dataToCompileMap[*itr] = *dtc;
                         }
                     }
@@ -645,5 +647,5 @@
 
                     // find all the compileable rendering objects
-                    DatabasePager::FindCompileableGLObjectsVisitor frov(dtc, 
+                    DatabasePager::FindCompileableGLObjectsVisitor frov(&dtc,
                                                          _pager->_changeAutoUnRef, _pager->_valueAutoUnRef,
                                                          _pager->_changeAnisotropy, _pager->_valueAnisotropy,
@@ -1494,5 +1496,5 @@
     }
 
-    META_NodeVisitor("osgDB","FindCompileableGLObjectsVisitor")
+    META_NodeVisitor("osgDB","MarkPagedLODsVisitor")
 
     virtual void apply(osg::PagedLOD& plod)
