[Bf-blender-cvs] [2e07af36fd3] blender2.8: Fix T56763: Removing driver variable crashes Blender.

Bastien Montagne noreply at git.blender.org
Wed Sep 12 17:49:40 CEST 2018


Commit: 2e07af36fd35c97d382300962bcb9695584a23f4
Author: Bastien Montagne
Date:   Wed Sep 12 17:40:48 2018 +0200
Branches: blender2.8
https://developer.blender.org/rB2e07af36fd35c97d382300962bcb9695584a23f4

Fix T56763: Removing driver variable crashes Blender.

Rebuilding depsgraph is not enough, with COW we also need to ensure COW
copies get updated accordingly.

Had to tweak the generic update system here, since it was always passed
a NULL pointer for the callback arg, this should not change existing
behavior (besides crash fixing ;) )...

===================================================================

M	source/blender/editors/space_graph/graph_buttons.c

===================================================================

diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 4162e6dec92..642e8e074fa 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -46,6 +46,7 @@
 
 #include "BLT_translation.h"
 
+#include "BKE_animsys.h"
 #include "BKE_context.h"
 #include "BKE_curve.h"
 #include "BKE_fcurve.h"
@@ -54,6 +55,7 @@
 #include "BKE_screen.h"
 #include "BKE_unit.h"
 
+#include "DEG_depsgraph.h"
 #include "DEG_depsgraph_build.h"
 
 #include "WM_api.h"
@@ -467,7 +469,7 @@ static void graph_panel_key_properties(const bContext *C, Panel *pa)
 
 #define B_IPO_DEPCHANGE     10
 
-static void do_graph_region_driver_buttons(bContext *C, void *fcu_v, int event)
+static void do_graph_region_driver_buttons(bContext *C, void *id_v, int event)
 {
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
@@ -475,6 +477,9 @@ static void do_graph_region_driver_buttons(bContext *C, void *fcu_v, int event)
 	switch (event) {
 		case B_IPO_DEPCHANGE:
 		{
+			/* Was not actually run ever (NULL always passed as arg to this callback).
+			 * If needed again, will need to check how to pass both fcurve and ID... :/ */
+#if 0
 			/* force F-Curve & Driver to get re-evaluated (same as the old Update Dependencies) */
 			FCurve *fcu = (FCurve *)fcu_v;
 			ChannelDriver *driver = (fcu) ? fcu->driver : NULL;
@@ -484,9 +489,22 @@ static void do_graph_region_driver_buttons(bContext *C, void *fcu_v, int event)
 				fcu->flag &= ~FCURVE_DISABLED;
 				driver->flag &= ~DRIVER_FLAG_INVALID;
 			}
+#endif
+			ID *id = id_v;
+			AnimData *adt = BKE_animdata_from_id(id);
 
-			/* rebuild depsgraph for the new deps */
+			/* rebuild depsgraph for the new deps, and ensure COW copies get flushed. */
 			DEG_relations_tag_update(bmain);
+			DEG_id_tag_update_ex(bmain, id, DEG_TAG_COPY_ON_WRITE);
+			if (adt != NULL) {
+				if (adt->action != NULL) {
+					DEG_id_tag_update_ex(bmain, &adt->action->id, DEG_TAG_COPY_ON_WRITE);
+				}
+				if (adt->tmpact != NULL) {
+					DEG_id_tag_update_ex(bmain, &adt->tmpact->id, DEG_TAG_COPY_ON_WRITE);
+				}
+			}
+
 			break;
 		}
 	}
@@ -759,7 +777,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, ID *id, FCurve *f
 
 	/* set event handler for panel */
 	block = uiLayoutGetBlock(layout);
-	UI_block_func_handle_set(block, do_graph_region_driver_buttons, NULL);
+	UI_block_func_handle_set(block, do_graph_region_driver_buttons, id);
 
 	/* driver-level settings - type, expressions, and errors */
 	RNA_pointer_create(id, &RNA_Driver, driver, &driver_ptr);



More information about the Bf-blender-cvs mailing list