Browse Source

Fix tinydisplay texture errors on shutdown

rdb 9 years ago
parent
commit
2e9394eba7

+ 1 - 0
doc/ReleaseNotes

@@ -38,6 +38,7 @@ This issue fixes several bugs that were still found in 1.9.2.
 * Fix is_playing() check when playing an animation backwards
 * Windows installer no longer clears %PATH% if longer than 1024 chars
 * Fix inoperative -tbn/-tbnall/-tbnauto options in egg-optchar
+* Fix tinydisplay texture errors on shutdown
 
 ------------------------  RELEASE 1.9.2  ------------------------
 

+ 1 - 16
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -1800,24 +1800,9 @@ update_texture(TextureContext *tc, bool force, int stage_index, bool uses_mipmap
 ////////////////////////////////////////////////////////////////////
 void TinyGraphicsStateGuardian::
 release_texture(TextureContext *tc) {
-  TinyTextureContext *gtc = DCAST(TinyTextureContext, tc);
-
   _texturing_state = 0;  // just in case
 
-  GLTexture *gltex = &gtc->_gltex;
-  if (gltex->allocated_buffer != NULL) {
-    nassertv(gltex->num_levels != 0);
-    TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount);
-    PANDA_FREE_ARRAY(gltex->allocated_buffer);
-    gltex->allocated_buffer = NULL;
-    gltex->total_bytecount = 0;
-    gltex->num_levels = 0;
-  } else {
-    nassertv(gltex->num_levels == 0);
-  }
-
-  gtc->dequeue_lru();
-
+  TinyTextureContext *gtc = DCAST(TinyTextureContext, tc);
   delete gtc;
 }
 

+ 0 - 10
panda/src/tinydisplay/tinyTextureContext.I

@@ -26,13 +26,3 @@ TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) :
   _gltex.allocated_buffer = NULL;
   _gltex.total_bytecount = 0;
 }
-
-////////////////////////////////////////////////////////////////////
-//     Function: TinyTextureContext::Destructor
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-INLINE TinyTextureContext::
-~TinyTextureContext() {
-  nassertv(_gltex.num_levels == 0 && _gltex.allocated_buffer == NULL && _gltex.total_bytecount == 0);
-}

+ 20 - 0
panda/src/tinydisplay/tinyTextureContext.cxx

@@ -17,6 +17,26 @@
 
 TypeHandle TinyTextureContext::_type_handle;
 
+////////////////////////////////////////////////////////////////////
+//     Function: TinyTextureContext::Destructor
+//       Access: Public
+//  Description: Releases the memory associated with the texture.
+////////////////////////////////////////////////////////////////////
+TinyTextureContext::
+~TinyTextureContext() {
+  GLTexture *gltex = &_gltex;
+  if (gltex->allocated_buffer != NULL) {
+    nassertv(gltex->num_levels != 0);
+    TinyTextureContext::get_class_type().dec_memory_usage(TypeHandle::MC_array, gltex->total_bytecount);
+    PANDA_FREE_ARRAY(gltex->allocated_buffer);
+    gltex->allocated_buffer = NULL;
+    gltex->total_bytecount = 0;
+    gltex->num_levels = 0;
+  } else {
+    nassertv(gltex->num_levels == 0);
+  }
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: TinyTextureContext::evict_lru
 //       Access: Public, Virtual

+ 1 - 1
panda/src/tinydisplay/tinyTextureContext.h

@@ -29,7 +29,7 @@ public:
   INLINE TinyTextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view);
   ALLOC_DELETED_CHAIN(TinyTextureContext);
 
-  INLINE ~TinyTextureContext();
+  ~TinyTextureContext();
 
   virtual void evict_lru();