[Bf-blender-cvs] [856077618a] master: Fix T50830: Wrong context when calling surfacedeform_bind

Luca Rood noreply at git.blender.org
Wed Mar 1 22:03:40 CET 2017


Commit: 856077618a9dfe33a6fb25c86effdfd2b3098419
Author: Luca Rood
Date:   Wed Mar 1 17:56:10 2017 -0300
Branches: master
https://developer.blender.org/rB856077618a9dfe33a6fb25c86effdfd2b3098419

Fix T50830: Wrong context when calling surfacedeform_bind

The custom poll function for surfacedeform_bind seems to have caused
issues when calling it from Python. Fixed by using the generic modifier
poll function, and setting the button to be active or not in the
Python UI code instead. (there might be a better way, but for now this
works fine)

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/editors/object/object_modifier.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index d62c20d458..68b6265ab1 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -960,10 +960,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         layout.separator()
 
+        col = layout.column()
+        col.active = md.target is not None
+
         if md.is_bound:
-            layout.operator("object.surfacedeform_bind", text="Unbind")
+            col.operator("object.surfacedeform_bind", text="Unbind")
         else:
-            layout.operator("object.surfacedeform_bind", text="Bind")
+            col.operator("object.surfacedeform_bind", text="Bind")
 
     def UV_PROJECT(self, layout, ob, md):
         split = layout.split()
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 38df1116cd..d601f5c3b1 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2299,14 +2299,7 @@ void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot)
 
 static int surfacedeform_bind_poll(bContext *C)
 {
-	if (edit_modifier_poll_generic(C, &RNA_SurfaceDeformModifier, 0)) {
-		PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_SurfaceDeformModifier);
-		SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)ptr.data;
-
-		return ((smd != NULL) && (smd->target != NULL));
-	}
-
-	return 0;
+	return edit_modifier_poll_generic(C, &RNA_SurfaceDeformModifier, 0);
 }
 
 static int surfacedeform_bind_exec(bContext *C, wmOperator *op)




More information about the Bf-blender-cvs mailing list