From a2de3d86de29575698f42a167b8d2c4acf05c38e Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Sun, 26 Apr 2020 16:02:18 +0200 Subject: Fix utterly wrong decorator button logic This was in fact completely messed up, but it worked by accident for all current cases. That is, we always inserted the decorator buttons immediately after the button they applied to. So the first button comparision in ui_but_anim_decorate_find_attached_button() would succeed, because it just compared a few values that all happened to be NULL and thus the comparison returned true. Further, avoid NULL-pointer dereferences and incorrect printing. --- source/blender/editors/interface/interface_anim.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'source/blender/editors/interface/interface_anim.c') diff --git a/source/blender/editors/interface/interface_anim.c b/source/blender/editors/interface/interface_anim.c index 877216daacc..ed591335660 100644 --- a/source/blender/editors/interface/interface_anim.c +++ b/source/blender/editors/interface/interface_anim.c @@ -123,10 +123,11 @@ static uiBut *ui_but_anim_decorate_find_attached_button(uiBut *but_decorate) BLI_assert(but_decorate->rnasearchpoin.data && but_decorate->rnasearchprop); LISTBASE_CIRCULAR_BACKWARD_BEGIN (&but_decorate->block->buttons, but_iter, but_decorate->prev) { - if (but_iter != but_decorate && ui_but_rna_equals_ex(but_decorate, - &but_iter->rnasearchpoin, - but_iter->rnasearchprop, - POINTER_AS_INT(but_iter->custom_data))) { + if (but_iter != but_decorate && + ui_but_rna_equals_ex(but_iter, + &but_decorate->rnasearchpoin, + but_decorate->rnasearchprop, + POINTER_AS_INT(but_decorate->custom_data))) { return but_iter; } } @@ -140,9 +141,10 @@ void ui_but_anim_decorate_update_from_flag(uiBut *but) const uiBut *but_anim = ui_but_anim_decorate_find_attached_button(but); if (!but_anim) { - printf("Could not find button with matching property to decorate (%s.%s)", - RNA_struct_identifier(but->rnapoin.type), - RNA_property_identifier(but->rnaprop)); + printf("Could not find button with matching property to decorate (%s.%s)\n", + RNA_struct_identifier(but->rnasearchpoin.type), + RNA_property_identifier(but->rnasearchprop)); + return; } int flag = but_anim->flag; -- cgit v1.2.3