Skip to content

Commit

Permalink
UPBGE: Fix mesh free from libload.
Browse files Browse the repository at this point in the history
When a mesh is deleted it destructs its mesh materials and then
the display array buckets used by the basic mesh. In the free of
the libloaded library (FreeBlendFile) the materials were free before
the meshes, but in the deletion of DAB it unregister the DAB from
the material bucket. This caused an issue as the material remove
also the material bucket and then the DAB used a dangling pointer
to unregister them.

Solution found by youle.
Fix issue: #607.
  • Loading branch information
panzergame committed Oct 8, 2017
1 parent bcfd59e commit 8c9ae8d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions source/gameengine/Converter/BL_BlenderConverter.cpp
Expand Up @@ -688,6 +688,16 @@ bool BL_BlenderConverter::FreeBlendFile(Main *maggie)
KX_Scene *scene = sit->first;
SceneSlot& sceneSlot = sit->second;

for (UniquePtrList<RAS_MeshObject>::iterator it = sceneSlot.m_meshobjects.begin(); it != sceneSlot.m_meshobjects.end(); ) {
RAS_MeshObject *mesh = (*it).get();
if (IS_TAGGED(mesh->GetMesh())) {
it = sceneSlot.m_meshobjects.erase(it);
}
else {
++it;
}
}

for (UniquePtrList<KX_BlenderMaterial>::iterator it = sceneSlot.m_materials.begin(); it != sceneSlot.m_materials.end(); ) {
KX_BlenderMaterial *mat = (*it).get();
Material *bmat = mat->GetBlenderMaterial();
Expand All @@ -711,16 +721,6 @@ bool BL_BlenderConverter::FreeBlendFile(Main *maggie)
++it;
}
}

for (UniquePtrList<RAS_MeshObject>::iterator it = sceneSlot.m_meshobjects.begin(); it != sceneSlot.m_meshobjects.end(); ) {
RAS_MeshObject *mesh = (*it).get();
if (IS_TAGGED(mesh->GetMesh())) {
it = sceneSlot.m_meshobjects.erase(it);
}
else {
++it;
}
}
}

#ifdef WITH_PYTHON
Expand Down

0 comments on commit 8c9ae8d

Please sign in to comment.