Fix T40172: LibFree() crashes with shared materials (e.g., from multiple LibNew() calls)

This commit is contained in:
Mitchell Stokes 2014-05-13 15:50:28 -07:00
parent 1d1560eec4
commit 23b682d594

@ -1237,6 +1237,16 @@ bool KX_BlenderSceneConverter::FreeBlendFile(struct Main *maggie)
gameobj->RemoveMeshes(); /* XXX - slack, should only remove meshes that are library items but mostly objects only have 1 mesh */ gameobj->RemoveMeshes(); /* XXX - slack, should only remove meshes that are library items but mostly objects only have 1 mesh */
break; break;
} }
else {
/* also free the mesh if it's using a tagged material */
int mat_index = mesh->NumMaterials();
while (mat_index--) {
if (IS_TAGGED(mesh->GetMeshMaterial(mat_index)->m_bucket->GetPolyMaterial()->GetBlenderMaterial())) {
gameobj->RemoveMeshes(); /* XXX - slack, same as above */
break;
}
}
}
} }
/* make sure action actuators are not referencing tagged actions */ /* make sure action actuators are not referencing tagged actions */