David Rose 18 years ago
parent
commit
77a7c6ab71

+ 13 - 0
panda/src/gobj/vertexDataSaveFile.I

@@ -16,3 +16,16 @@
 //
 ////////////////////////////////////////////////////////////////////
 
+
+////////////////////////////////////////////////////////////////////
+//     Function: VertexDataSaveFile::is_valid
+//       Access: Public
+//  Description: Returns true if the save file was successfully
+//               created and is ready for use, false if there was an
+//               error.
+////////////////////////////////////////////////////////////////////
+INLINE bool VertexDataSaveFile::
+is_valid() const {
+  return _is_valid;
+}
+

+ 8 - 0
panda/src/gobj/vertexDataSaveFile.cxx

@@ -169,6 +169,10 @@ VertexDataSaveFile::
 ////////////////////////////////////////////////////////////////////
 SimpleAllocatorBlock *VertexDataSaveFile::
 write_data(const unsigned char *data, size_t size) {
+  if (!_is_valid) {
+    return NULL;
+  }
+
   SimpleAllocatorBlock *block = _allocator.alloc(size);
   if (block != (SimpleAllocatorBlock *)NULL) {
 
@@ -218,6 +222,10 @@ write_data(const unsigned char *data, size_t size) {
 ////////////////////////////////////////////////////////////////////
 bool VertexDataSaveFile::
 read_data(unsigned char *data, size_t size, SimpleAllocatorBlock *block) {
+  if (!_is_valid) {
+    return false;
+  }
+
   nassertr(size == block->get_size(), false);
 
 #ifdef _WIN32

+ 2 - 0
panda/src/gobj/vertexDataSaveFile.h

@@ -41,6 +41,8 @@ public:
                      size_t max_size);
   ~VertexDataSaveFile();
 
+  INLINE bool is_valid() const;
+  
   SimpleAllocatorBlock *write_data(const unsigned char *data, size_t size);
   bool read_data(unsigned char *data, size_t size,
                  SimpleAllocatorBlock *block);