fix crash

This commit is contained in:
David Rose 2008-07-23 21:57:39 +00:00
parent 227ed2dc45
commit 63f0e86da0
2 changed files with 9 additions and 6 deletions

View File

@ -97,7 +97,7 @@ do_zlib_free(voidpf opaque, voidpf address) {
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: VertexDataPage::Book Constructor // Function: VertexDataPage::Book Constructor
// Access: Public // Access: Private
// Description: This constructor is used only by VertexDataBook, to // Description: This constructor is used only by VertexDataBook, to
// create a mostly-empty object that can be used to // create a mostly-empty object that can be used to
// search for a particular page size in the set. // search for a particular page size in the set.
@ -119,7 +119,7 @@ VertexDataPage(size_t book_size) :
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: VertexDataPage::Constructor // Function: VertexDataPage::Constructor
// Access: Public // Access: Private
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
VertexDataPage:: VertexDataPage::
@ -141,7 +141,7 @@ VertexDataPage(VertexDataBook *book, size_t page_size, size_t block_size) :
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: VertexDataPage::Destructor // Function: VertexDataPage::Destructor
// Access: Public // Access: Private, Virtual
// Description: // Description:
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
VertexDataPage:: VertexDataPage::
@ -163,6 +163,8 @@ VertexDataPage::
free_page_data(_page_data, _allocated_size); free_page_data(_page_data, _allocated_size);
_size = 0; _size = 0;
} }
nassertv(_book == NULL);
} }
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
@ -240,6 +242,7 @@ changed_contiguous() {
VertexDataBook::Pages::iterator pi = _book->_pages.find(this); VertexDataBook::Pages::iterator pi = _book->_pages.find(this);
nassertv(pi != _book->_pages.end()); nassertv(pi != _book->_pages.end());
_book->_pages.erase(pi); _book->_pages.erase(pi);
_book = NULL;
delete this; delete this;
return; return;
} }
@ -692,7 +695,7 @@ adjust_book_size() {
new_size = 0; new_size = 0;
} }
if (new_size != _book_size) { if (_book != (VertexDataBook *)NULL && new_size != _book_size) {
VertexDataBook::Pages::iterator pi = _book->_pages.find(this); VertexDataBook::Pages::iterator pi = _book->_pages.find(this);
nassertv(pi != _book->_pages.end()); nassertv(pi != _book->_pages.end());
_book->_pages.erase(pi); _book->_pages.erase(pi);

View File

@ -38,10 +38,10 @@ class VertexDataBlock;
// cache file, if necessary. // cache file, if necessary.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
class EXPCL_PANDA_GOBJ VertexDataPage : public SimpleAllocator, public SimpleLruPage { class EXPCL_PANDA_GOBJ VertexDataPage : public SimpleAllocator, public SimpleLruPage {
public: private:
VertexDataPage(size_t book_size); VertexDataPage(size_t book_size);
VertexDataPage(VertexDataBook *book, size_t page_size, size_t block_size); VertexDataPage(VertexDataBook *book, size_t page_size, size_t block_size);
~VertexDataPage(); virtual ~VertexDataPage();
PUBLISHED: PUBLISHED:
// These are used to indicate the current residency state of the // These are used to indicate the current residency state of the