Depsgrpah: Fix crash when removing object

This commit is contained in:
2017-10-18 16:43:40 +02:00
parent 47bcd4abad
commit 651f76b384

View File

@@ -309,24 +309,26 @@ IDDepsNode *Depsgraph::add_id_node(ID *id, bool do_tag, ID *id_cow_hint)
void Depsgraph::clear_id_nodes() void Depsgraph::clear_id_nodes()
{ {
/* Stupid workaround to ensure we free IDs in a proper order. */ if (use_copy_on_write) {
GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash) /* Stupid workaround to ensure we free IDs in a proper order. */
{ GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash)
if (id_node->id_cow == NULL) { {
/* This means builder "stole" ownership of the copy-on-written if (id_node->id_cow == NULL) {
* datablock for her own dirty needs. /* This means builder "stole" ownership of the copy-on-written
*/ * datablock for her own dirty needs.
continue; */
} continue;
if (!deg_copy_on_write_is_expanded(id_node->id_cow)) { }
continue; if (!deg_copy_on_write_is_expanded(id_node->id_cow)) {
} continue;
const ID_Type id_type = GS(id_node->id_cow->name); }
if (id_type != ID_PA) { const ID_Type id_type = GS(id_node->id_cow->name);
id_node->destroy(); if (id_type != ID_PA) {
id_node->destroy();
}
} }
GHASH_FOREACH_END();
} }
GHASH_FOREACH_END();
GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash) GHASH_FOREACH_BEGIN(IDDepsNode *, id_node, id_hash)
{ {
OBJECT_GUARDED_DELETE(id_node, IDDepsNode); OBJECT_GUARDED_DELETE(id_node, IDDepsNode);