Address some rare crashes at shutdown

This commit is contained in:
rdb 2015-10-31 04:11:12 +01:00
parent fe633b51a1
commit d3494edf2c
4 changed files with 32 additions and 5 deletions

View File

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

View File

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

View File

@ -257,6 +257,32 @@ get_global_ptr() {
return _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 // Function: BamCache::mark_index_stale
// Access: Private // Access: Private

View File

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