From 520520796e7a373db7d83cbae363edfbdf58228f Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sat, 12 Jan 2019 15:37:29 -0500 Subject: [PATCH] Welcome to HAXLand. Population: Hoikas. See the comment for details. I've been seeing this crash since we started doing fancy idprop stuff. Of course, my test blend has always had bleeding edge junk and has crashed left, right, and center. For more fun, follow the progress on D4196. --- korman/nodes/node_core.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/korman/nodes/node_core.py b/korman/nodes/node_core.py index 31c31ac..9710b53 100644 --- a/korman/nodes/node_core.py +++ b/korman/nodes/node_core.py @@ -384,3 +384,17 @@ class PlasmaNodeTree(bpy.types.NodeTree): @classmethod def poll(cls, context): return (context.scene.render.engine == "PLASMA_GAME") + + +# Welcome to HAXland! +# Blender 2.79 is great in that it allows us to have ID Datablock pointer properties everywhere. +# However, there is an error in the way user refcounts are handled in node trees. When a node is freed, +# it always decrements the user count. Good. But, the node tree decrements that same count again, resulting +# in a use-after-free (or double-free?) crash in Blender. I modelled and submitted a fix (see: Blender D4196) +# but a workaround is to just remove the nodes from all Plasma node trees before the data is unloaded. :) +@bpy.app.handlers.persistent +def _nuke_plasma_nodes(dummy): + for i in bpy.data.node_groups: + if isinstance(i, PlasmaNodeTree): + i.nodes.clear() +bpy.app.handlers.load_pre.append(_nuke_plasma_nodes)