From 9314f97afd72fe9bfa3316f2604e904ea5bbb671 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Mon, 10 Jul 2023 10:11:43 +0200 Subject: [PATCH] Fix #109887: Adding driver from python might crash Originally was noticed when adding drivers to a rigid body., but it could potentially happen with any configuration. The reason for the crash was that the ID which was modified was not tagged as such. Modifying drivers from the interface are likely tagging for updates from the operator. This change makes it so the python function also does tagging. It is not really how one would design the system nowadays, but it is how the Blender historically handles such cases. A bigger refactor is possible to move tags to the places where modification actually happens, but it seems to be a better idea to tackle it as a separate project which will be considered no-functional-changes. Pull Request: https://projects.blender.org/blender/blender/pulls/109895 --- source/blender/python/intern/bpy_rna_anim.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/blender/python/intern/bpy_rna_anim.c b/source/blender/python/intern/bpy_rna_anim.c index 71106a0f486..4ad40559d61 100644 --- a/source/blender/python/intern/bpy_rna_anim.c +++ b/source/blender/python/intern/bpy_rna_anim.c @@ -47,6 +47,7 @@ #include "../generic/py_capi_rna.h" #include "../generic/python_utildefines.h" +#include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" /* for keyframes and drivers */ @@ -588,6 +589,7 @@ PyObject *pyrna_struct_driver_add(BPy_StructRNA *self, PyObject *args) bContext *context = BPY_context_get(); WM_event_add_notifier(BPY_context_get(), NC_ANIMATION | ND_FCURVES_ORDER, NULL); + DEG_id_tag_update(id, ID_RECALC_COPY_ON_WRITE); DEG_relations_tag_update(CTX_data_main(context)); } else {