From bab46b4f029e7846ff3f946efb57e53f534b7d15 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Thu, 20 Jun 2024 17:02:55 +0200 Subject: [PATCH] Fix: Crash opening new file after having one open with Subsirf There is some special code in the Object's freeing which did special checks for SubdivCCG based on the evaluated mesh state. If the depsgraph is destroyed prior to the evaluated object it makes object to access freed components of ID node. The fix makes it so the evaluated ID is freed prior to freeing components. --- source/blender/depsgraph/intern/node/deg_node_id.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc index 61f627e4f77..791134e76d1 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.cc +++ b/source/blender/depsgraph/intern/node/deg_node_id.cc @@ -116,10 +116,6 @@ void IDNode::destroy() return; } - for (ComponentNode *comp_node : components.values()) { - delete comp_node; - } - /* Free memory used by this evaluated ID. */ if (!ELEM(id_cow, id_orig, nullptr)) { deg_free_eval_copy_datablock(id_cow); @@ -129,6 +125,10 @@ void IDNode::destroy() "Destroy evaluated ID for %s: id_orig=%p id_cow=%p\n", id_orig->name, id_orig, id_cow); } + for (ComponentNode *comp_node : components.values()) { + delete comp_node; + } + /* Tag that the node is freed. */ id_orig = nullptr; }