Browse Source

Address some rare crashes at shutdown

rdb 10 years ago
parent
commit
d3494edf2c

+ 2 - 1
direct/src/showbase/ShowBase.py

@@ -296,7 +296,6 @@ class ShowBase(DirectObject.DirectObject):
         self.physicsMgrEnabled = 0
         self.physicsMgrAngular = 0
 
-        self.createBaseAudioManagers()
         self.createStats()
 
         self.AppHasAudioFocus = 1
@@ -384,6 +383,8 @@ class ShowBase(DirectObject.DirectObject):
         else:
             ShowBase.notify.info('__dev__ == %s' % __dev__)
 
+        self.createBaseAudioManagers()
+
         # set up recording of Functor creation stacks in __dev__
         PythonUtil.recordFunctorCreationStacks()
 

+ 2 - 4
panda/src/display/graphicsEngine.cxx

@@ -630,8 +630,7 @@ remove_all_windows() {
   // a hack, since it's not really related to removing windows, this
   // would nevertheless be a fine time to ensure the model cache (if
   // any) has been flushed to disk.
-  BamCache *cache = BamCache::get_global_ptr();
-  cache->flush_index();
+  BamCache::flush_global_index();
 
   // And, hey, let's stop the vertex paging threads, if any.
   VertexDataPage::stop_threads();
@@ -716,8 +715,7 @@ render_frame() {
 
   // Since this gets called every frame, we should take advantage of
   // the opportunity to flush the cache if necessary.
-  BamCache *cache = BamCache::get_global_ptr();
-  cache->consider_flush_index();
+  BamCache::consider_flush_global_index();
 
   // Anything that happens outside of GraphicsEngine::render_frame()
   // is deemed to be App.

+ 26 - 0
panda/src/putil/bamCache.I

@@ -257,6 +257,32 @@ get_global_ptr() {
   return _global_ptr;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: BamCache::consider_flush_global_index
+//       Access: Published, Static
+//  Description: If there is a global BamCache object, calls
+//               consider_flush_index() on it.
+////////////////////////////////////////////////////////////////////
+INLINE void BamCache::
+consider_flush_global_index() {
+  if (_global_ptr != (BamCache *)NULL) {
+    _global_ptr->consider_flush_index();
+  }
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: BamCache::flush_global_index
+//       Access: Published, Static
+//  Description: If there is a global BamCache object, calls
+//               flush_index() on it.
+////////////////////////////////////////////////////////////////////
+INLINE void BamCache::
+flush_global_index() {
+  if (_global_ptr != (BamCache *)NULL) {
+    _global_ptr->flush_index();
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: BamCache::mark_index_stale
 //       Access: Private

+ 2 - 0
panda/src/putil/bamCache.h

@@ -83,6 +83,8 @@ PUBLISHED:
   void list_index(ostream &out, int indent_level = 0) const;
 
   INLINE static BamCache *get_global_ptr();
+  INLINE static void consider_flush_global_index();
+  INLINE static void flush_global_index();
 
 private:
   void read_index();