mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
prevent occasional assertion failure
This commit is contained in:
parent
36c0a0fd2e
commit
f6030da8bc
@ -244,30 +244,36 @@ store(BamCacheRecord *record) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BamWriter writer(&dout, temp_pathname);
|
{
|
||||||
if (!writer.init()) {
|
BamWriter writer(&dout, temp_pathname);
|
||||||
temp_pathname.unlink();
|
if (!writer.init()) {
|
||||||
return false;
|
temp_pathname.unlink();
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
TypeRegistry *type_registry = TypeRegistry::ptr();
|
||||||
|
TypeHandle texture_type = type_registry->find_type("Texture");
|
||||||
|
if (record->get_data()->is_of_type(texture_type)) {
|
||||||
|
// Texture objects write the actual texture image.
|
||||||
|
writer.set_file_texture_mode(BTM_rawdata);
|
||||||
|
} else {
|
||||||
|
// Any other kinds of objects write texture references.
|
||||||
|
writer.set_file_texture_mode(BTM_fullpath);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!writer.write_object(record)) {
|
||||||
|
temp_pathname.unlink();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!writer.write_object(record->get_data())) {
|
||||||
|
temp_pathname.unlink();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
TypeRegistry *type_registry = TypeRegistry::ptr();
|
// Now that we are done with the BamWriter, it's important to let
|
||||||
TypeHandle texture_type = type_registry->find_type("Texture");
|
// it destruct now and clean itself up, or it might get mad if we
|
||||||
if (record->get_data()->is_of_type(texture_type)) {
|
// delete any TypedWritables below that haven't been written yet.
|
||||||
// Texture objects write the actual texture image.
|
|
||||||
writer.set_file_texture_mode(BTM_rawdata);
|
|
||||||
} else {
|
|
||||||
// Any other kinds of objects write texture references.
|
|
||||||
writer.set_file_texture_mode(BTM_fullpath);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!writer.write_object(record)) {
|
|
||||||
temp_pathname.unlink();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!writer.write_object(record->get_data())) {
|
|
||||||
temp_pathname.unlink();
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
record->_record_size = temp_file.tellp();
|
record->_record_size = temp_file.tellp();
|
||||||
@ -752,15 +758,17 @@ do_write_index(Filename &index_pathname, const BamCacheIndex *index) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BamWriter writer(&dout, index_pathname);
|
{
|
||||||
if (!writer.init()) {
|
BamWriter writer(&dout, index_pathname);
|
||||||
index_pathname.unlink();
|
if (!writer.init()) {
|
||||||
return false;
|
index_pathname.unlink();
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
if (!writer.write_object(index)) {
|
|
||||||
index_pathname.unlink();
|
if (!writer.write_object(index)) {
|
||||||
return false;
|
index_pathname.unlink();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
index_file.close();
|
index_file.close();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user