fix crash from bam files

This commit is contained in:
David Rose 2005-04-20 16:48:04 +00:00
parent 46cdf502bb
commit 4f6c012c77
3 changed files with 25 additions and 0 deletions

View File

@ -594,6 +594,27 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) {
return pi;
}
////////////////////////////////////////////////////////////////////
// Function: qpGeomVertexArrayFormat::finalize
// Access: Public, Virtual
// Description: Called by the BamReader to perform any final actions
// needed for setting up the object after all objects
// have been read and all pointers have been completed.
////////////////////////////////////////////////////////////////////
void qpGeomVertexArrayFormat::
finalize(BamReader *manager) {
// Now we can build up the _columns_by_name index. We have to wait
// until finalize(), since the index is based on the nested name
// pointer within each column, which might not be available at the
// time complete_pointers() is called.
_columns_by_name.clear();
Columns::iterator ci;
for (ci = _columns.begin(); ci != _columns.end(); ++ci) {
qpGeomVertexColumn *column = (*ci);
_columns_by_name.insert(ColumnsByName::value_type(column->get_name(), column));
}
}
////////////////////////////////////////////////////////////////////
// Function: qpGeomVertexArrayFormat::make_from_bam
// Access: Protected, Static
@ -611,6 +632,7 @@ make_from_bam(const FactoryParams &params) {
parse_params(params, scan, manager);
object->fillin(scan, manager);
manager->register_finalize(object);
return object;
}

View File

@ -156,6 +156,8 @@ public:
virtual void write_datagram(BamWriter *manager, Datagram &dg);
virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
virtual void finalize(BamReader *manager);
protected:
static TypedWritable *make_from_bam(const FactoryParams &params);
void fillin(DatagramIterator &scan, BamReader *manager);

View File

@ -445,6 +445,7 @@ copy_from(const qpGeomVertexData *source, bool keep_data_objects) {
dest_format->get_array(dest_i);
const qpGeomVertexColumn *dest_column =
dest_array_format->get_column(source_column->get_name());
nassertv(dest_column != (const qpGeomVertexColumn *)NULL);
if (dest_column->is_bytewise_equivalent(*source_column)) {
// We can do a quick bytewise copy.