Commit: 5a17cb4c0825d3eab3daaff3dc6c27eb986f35f6
Author: Luca Rood
Date:   Tue Feb 14 16:33:24 2017 -0200
Branches: surface-deform-modifier
https://developer.blender.org/rB5a17cb4c0825d3eab3daaff3dc6c27eb986f35f6

Use poll callback to disable bind operator instead of Python

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

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 68e1b3b210..daa5ff2d39 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -956,13 +956,10 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
 
         layout.separator()
 
-        col = layout.column()
-        col.active = md.target is not None
-
         if md.is_bound:
-            col.operator("object.surfacedeform_bind", text="Unbind")
+            layout.operator("object.surfacedeform_bind", text="Unbind")
         else:
-            col.operator("object.surfacedeform_bind", text="Bind")
+            layout.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 38222fafd8..56e94c28d2 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -2297,15 +2297,22 @@ void OBJECT_OT_laplaciandeform_bind(wmOperatorType *ot)
 
 /************************ sdef bind operator *********************/
 
-static int surfacedeform_poll(bContext *C)
+static int surfacedeform_bind_poll(bContext *C)
 {
-       return edit_modifier_poll_generic(C, &RNA_SurfaceDeformModifier, 0);
+       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;
 }
 
 static int surfacedeform_bind_exec(bContext *C, wmOperator *op)
 {
        Object *ob = ED_object_active_context(C);
-       SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *) 
edit_modifier_property_get(op, ob, eModifierType_SurfaceDeform);
+       SurfaceDeformModifierData *smd = (SurfaceDeformModifierData 
*)edit_modifier_property_get(op, ob, eModifierType_SurfaceDeform);
 
        if (!smd)
                return OPERATOR_CANCELLED;
@@ -2339,7 +2346,7 @@ void OBJECT_OT_surfacedeform_bind(wmOperatorType *ot)
        ot->idname = "OBJECT_OT_surfacedeform_bind";
 
        /* api callbacks */
-       ot->poll = surfacedeform_poll;
+       ot->poll = surfacedeform_bind_poll;
        ot->invoke = surfacedeform_bind_invoke;
        ot->exec = surfacedeform_bind_exec;

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to