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.
This commit is contained in:
Julian Eisel 2020-04-26 16:02:18 +02:00
parent 066b0248df
commit a2de3d86de
1 changed files with 9 additions and 7 deletions

View File

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