gobj: fix _contexts != nullptr assert when prepare fails

This commit is contained in:
rdb 2023-10-09 16:52:45 +02:00
parent dcc96a60b1
commit a2fa54f385
2 changed files with 22 additions and 12 deletions

View File

@ -239,19 +239,24 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const {
VertexBufferContext *GeomVertexArrayData::
prepare_now(PreparedGraphicsObjects *prepared_objects,
GraphicsStateGuardianBase *gsg) {
if (_contexts == nullptr) {
_contexts = new Contexts;
}
if (_contexts != nullptr) {
Contexts::const_iterator ci;
ci = _contexts->find(prepared_objects);
if (ci != _contexts->end()) {
return (*ci).second;
}
} else {
_contexts = new Contexts;
}
VertexBufferContext *vbc = prepared_objects->prepare_vertex_buffer_now(this, gsg);
if (vbc != nullptr) {
(*_contexts)[prepared_objects] = vbc;
}
else if (_contexts->empty()) {
delete _contexts;
_contexts = nullptr;
}
return vbc;
}

View File

@ -76,19 +76,24 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const {
BufferContext *ShaderBuffer::
prepare_now(PreparedGraphicsObjects *prepared_objects,
GraphicsStateGuardianBase *gsg) {
if (_contexts == nullptr) {
_contexts = new Contexts;
}
if (_contexts != nullptr) {
Contexts::const_iterator ci;
ci = _contexts->find(prepared_objects);
if (ci != _contexts->end()) {
return (*ci).second;
}
} else {
_contexts = new Contexts;
}
BufferContext *vbc = prepared_objects->prepare_shader_buffer_now(this, gsg);
if (vbc != nullptr) {
(*_contexts)[prepared_objects] = vbc;
}
else if (_contexts->empty()) {
delete _contexts;
_contexts = nullptr;
}
return vbc;
}