Skip to content

Commit

Permalink
gobj: fix _contexts != nullptr assert when prepare fails
Browse files Browse the repository at this point in the history
  • Loading branch information
rdb committed Oct 9, 2023
1 parent dcc96a6 commit a2fa54f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
17 changes: 11 additions & 6 deletions panda/src/gobj/geomVertexArrayData.cxx
Expand Up @@ -239,19 +239,24 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const {
VertexBufferContext *GeomVertexArrayData::
prepare_now(PreparedGraphicsObjects *prepared_objects,
GraphicsStateGuardianBase *gsg) {
if (_contexts == nullptr) {
if (_contexts != nullptr) {
Contexts::const_iterator ci;
ci = _contexts->find(prepared_objects);
if (ci != _contexts->end()) {
return (*ci).second;
}
} else {
_contexts = new Contexts;
}
Contexts::const_iterator ci;
ci = _contexts->find(prepared_objects);
if (ci != _contexts->end()) {
return (*ci).second;
}

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;
}

Expand Down
17 changes: 11 additions & 6 deletions panda/src/gobj/shaderBuffer.cxx
Expand Up @@ -76,19 +76,24 @@ is_prepared(PreparedGraphicsObjects *prepared_objects) const {
BufferContext *ShaderBuffer::
prepare_now(PreparedGraphicsObjects *prepared_objects,
GraphicsStateGuardianBase *gsg) {
if (_contexts == nullptr) {
if (_contexts != nullptr) {
Contexts::const_iterator ci;
ci = _contexts->find(prepared_objects);
if (ci != _contexts->end()) {
return (*ci).second;
}
} else {
_contexts = new Contexts;
}
Contexts::const_iterator ci;
ci = _contexts->find(prepared_objects);
if (ci != _contexts->end()) {
return (*ci).second;
}

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;
}

Expand Down

0 comments on commit a2fa54f

Please sign in to comment.