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)
This commit is contained in:
Luca Rood 2017-03-01 17:56:10 -03:00
parent 193827e59b
commit 856077618a
Notes: blender-bot 2023-02-14 08:42:53 +01:00
Referenced by issue #50838, Surface Deform Modifier produces inconsistent results when used on multiple objects
Referenced by issue #50828, Grace Pencil crashes when try to use OpenGL render active viewport via Video Sequence Editor
Referenced by issue #50830, surfacedeform_bind(modifier="Surface Deform") - context incorrect
Referenced by issue #50565, Transform: Planar constraints don't work properly with non-Blender key configurations
2 changed files with 6 additions and 10 deletions

View File

@ -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()

View File

@ -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)