[Bf-blender-cvs] [1de3c81d268] master: Fix T63431: crash adding driver to a keyframed property with Ctrl+D

Brecht Van Lommel noreply at git.blender.org
Sun Apr 21 02:36:28 CEST 2019


Commit: 1de3c81d268ba67128b2dd67335523a94320b0d2
Author: Brecht Van Lommel
Date:   Sun Apr 21 02:34:26 2019 +0200
Branches: master
https://developer.blender.org/rB1de3c81d268ba67128b2dd67335523a94320b0d2

Fix T63431: crash adding driver to a keyframed property with Ctrl+D

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

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

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

diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c
index d6564be9574..92c292f67e8 100644
--- a/source/blender/editors/animation/drivers.c
+++ b/source/blender/editors/animation/drivers.c
@@ -899,10 +899,21 @@ static bool add_driver_button_poll(bContext *C)
   PointerRNA ptr = {{NULL}};
   PropertyRNA *prop = NULL;
   int index;
+  bool driven, special;
 
   /* this operator can only run if there's a property button active, and it can be animated */
   UI_context_active_but_prop_get(C, &ptr, &prop, &index);
-  return (ptr.id.data && ptr.data && prop && RNA_property_animateable(&ptr, prop));
+
+  if (!(ptr.id.data && ptr.data && prop)) {
+    return false;
+  }
+  if (!RNA_property_animateable(&ptr, prop)) {
+    return false;
+  }
+
+  /* Don't do anything if there is an fcurve for animation without a driver. */
+  FCurve *fcu = rna_get_fcurve_context_ui(C, &ptr, prop, index, NULL, NULL, &driven, &special);
+  return (fcu == NULL || fcu->driver);
 }
 
 /* Wrapper for creating a driver without knowing what the targets will be yet (i.e. "manual/add later") */
diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c
index 8742f5d408c..20ddf434f5f 100644
--- a/source/blender/editors/space_graph/graph_buttons.c
+++ b/source/blender/editors/space_graph/graph_buttons.c
@@ -1255,7 +1255,7 @@ static void graph_panel_drivers_popover(const bContext *C, Panel *pa)
     uiLayoutSetContextFromBut(layout, but);
 
     /* Populate Panel - With a combination of the contents of the Driven and Driver panels */
-    if (fcu) {
+    if (fcu && fcu->driver) {
       ID *id = ptr.id.data;
 
       /* Driven Property Settings */



More information about the Bf-blender-cvs mailing list