Code Cleanup: remove redundant NULL checks and add function attributes
This commit is contained in:
parent
1728c1e284
commit
44855f9ef2
|
@ -1185,9 +1185,14 @@ void uiDrawBlock(const bContext *C, uiBlock *block)
|
|||
|
||||
/* ************* EVENTS ************* */
|
||||
|
||||
/**
|
||||
* Check if the button is pushed, this is only meaningful for some button types.
|
||||
*
|
||||
* \return (0 == UNSELECT), (1 == SELECT), (-1 == DO-NOHING)
|
||||
*/
|
||||
int ui_is_but_push_ex(uiBut *but, double *value)
|
||||
{
|
||||
int is_push = false; /* (0 == UNSELECT), (1 == SELECT), (-1 == DO-NOHING) */
|
||||
int is_push = false;
|
||||
|
||||
if (but->bit) {
|
||||
const bool state = ELEM3(but->type, TOGN, ICONTOGN, OPTIONN) ? false : true;
|
||||
|
@ -1940,7 +1945,7 @@ bool ui_set_but_string(bContext *C, uiBut *but, const char *str)
|
|||
PointerRNA ptr, rptr;
|
||||
PropertyRNA *prop;
|
||||
|
||||
if (str == NULL || str[0] == '\0') {
|
||||
if (str[0] == '\0') {
|
||||
RNA_property_pointer_set(&but->rnapoin, but->rnaprop, PointerRNA_NULL);
|
||||
return true;
|
||||
}
|
||||
|
@ -2551,7 +2556,7 @@ void uiBlockEndAlign(uiBlock *block)
|
|||
block->flag &= ~UI_BUT_ALIGN; /* all 4 flags */
|
||||
}
|
||||
|
||||
int ui_but_can_align(uiBut *but)
|
||||
bool ui_but_can_align(uiBut *but)
|
||||
{
|
||||
return !ELEM5(but->type, LABEL, OPTION, OPTIONN, SEPR, SEPRLINE);
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ void ui_but_anim_flag(uiBut *but, float cfra)
|
|||
}
|
||||
}
|
||||
|
||||
int ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
|
||||
bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
|
||||
{
|
||||
FCurve *fcu;
|
||||
ChannelDriver *driver;
|
||||
|
@ -99,14 +99,14 @@ int ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen)
|
|||
|
||||
if (driver && driver->type == DRIVER_TYPE_PYTHON) {
|
||||
BLI_strncpy(str, driver->expression, maxlen);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
int ui_but_anim_expression_set(uiBut *but, const char *str)
|
||||
bool ui_but_anim_expression_set(uiBut *but, const char *str)
|
||||
{
|
||||
FCurve *fcu;
|
||||
ChannelDriver *driver;
|
||||
|
@ -121,15 +121,15 @@ int ui_but_anim_expression_set(uiBut *but, const char *str)
|
|||
BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression));
|
||||
driver->flag |= DRIVER_FLAG_RECOMPILE;
|
||||
WM_event_add_notifier(but->block->evil_C, NC_ANIMATION | ND_KEYFRAME, NULL);
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* create new expression for button (i.e. a "scripted driver"), if it can be created... */
|
||||
int ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
bool ui_but_anim_expression_create(uiBut *but, const char *str)
|
||||
{
|
||||
bContext *C = but->block->evil_C;
|
||||
ID *id;
|
||||
|
@ -141,14 +141,14 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
|
|||
if (ELEM(NULL, but->rnapoin.data, but->rnaprop)) {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("ERROR: create expression failed - button has no RNA info attached\n");
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RNA_property_array_check(but->rnaprop) != 0) {
|
||||
if (but->rnaindex == -1) {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("ERROR: create expression failed - can't create expression for entire array\n");
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ int ui_but_anim_expression_create(uiBut *but, const char *str)
|
|||
if ((id == NULL) || (GS(id->name) == ID_MA) || (GS(id->name) == ID_TE)) {
|
||||
if (G.debug & G_DEBUG)
|
||||
printf("ERROR: create expression failed - invalid id-datablock for adding drivers (%p)\n", id);
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* get path */
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#ifndef __INTERFACE_INTERN_H__
|
||||
#define __INTERFACE_INTERN_H__
|
||||
|
||||
#include "BLI_compiler_attrs.h"
|
||||
#include "UI_resources.h"
|
||||
#include "RNA_types.h"
|
||||
|
||||
|
@ -366,7 +367,7 @@ extern void ui_delete_linkline(uiLinkLine *line, uiBut *but);
|
|||
|
||||
void ui_fontscale(short *points, float aspect);
|
||||
|
||||
extern bool ui_block_is_menu(const uiBlock *block);
|
||||
extern bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT;
|
||||
extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
|
||||
extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y);
|
||||
extern void ui_block_to_window_rctf(const struct ARegion *ar, uiBlock *block, rctf *rct_dst, const rctf *rct_src);
|
||||
|
@ -386,25 +387,25 @@ extern void ui_hsvcircle_pos_from_vals(struct uiBut *but, const rcti *rect, floa
|
|||
extern void ui_hsvcube_pos_from_vals(struct uiBut *but, const rcti *rect, float *hsv, float *xp, float *yp);
|
||||
bool ui_hsvcube_use_display_colorspace(struct uiBut *but);
|
||||
|
||||
extern void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision);
|
||||
extern void ui_get_but_string(uiBut *but, char *str, const size_t maxlen);
|
||||
extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen);
|
||||
extern bool ui_set_but_string(struct bContext *C, uiBut *but, const char *str);
|
||||
extern bool ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value);
|
||||
extern void ui_get_but_string_ex(uiBut *but, char *str, const size_t maxlen, const int float_precision) ATTR_NONNULL();
|
||||
extern void ui_get_but_string(uiBut *but, char *str, const size_t maxlen) ATTR_NONNULL();
|
||||
extern void ui_convert_to_unit_alt_name(uiBut *but, char *str, size_t maxlen) ATTR_NONNULL();
|
||||
extern bool ui_set_but_string(struct bContext *C, uiBut *but, const char *str) ATTR_NONNULL();
|
||||
extern bool ui_set_but_string_eval_num(struct bContext *C, uiBut *but, const char *str, double *value) ATTR_NONNULL();
|
||||
extern int ui_get_but_string_max_length(uiBut *but);
|
||||
|
||||
extern void ui_set_but_default(struct bContext *C, const bool all, const bool use_afterfunc);
|
||||
|
||||
extern void ui_check_but(uiBut *but);
|
||||
extern bool ui_is_but_float(const uiBut *but);
|
||||
extern bool ui_is_but_bool(const uiBut *but);
|
||||
extern bool ui_is_but_unit(const uiBut *but);
|
||||
extern bool ui_is_but_rna_valid(uiBut *but);
|
||||
extern bool ui_is_but_utf8(const uiBut *but);
|
||||
extern bool ui_is_but_search_unlink_visible(const uiBut *but);
|
||||
extern bool ui_is_but_float(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
extern bool ui_is_but_bool(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
extern bool ui_is_but_unit(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
extern bool ui_is_but_rna_valid(uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
extern bool ui_is_but_utf8(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
extern bool ui_is_but_search_unlink_visible(const uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
extern int ui_is_but_push_ex(uiBut *but, double *value);
|
||||
extern int ui_is_but_push(uiBut *but);
|
||||
extern int ui_is_but_push_ex(uiBut *but, double *value) ATTR_WARN_UNUSED_RESULT;
|
||||
extern int ui_is_but_push(uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
|
||||
|
||||
extern void ui_bounds_block(uiBlock *block);
|
||||
|
@ -520,7 +521,7 @@ extern void ui_pan_to_scroll(const struct wmEvent *event, int *type, int *val);
|
|||
extern void ui_button_activate_do(struct bContext *C, struct ARegion *ar, uiBut *but);
|
||||
extern void ui_button_execute_do(struct bContext *C, struct ARegion *ar, uiBut *but);
|
||||
extern void ui_button_active_free(const struct bContext *C, uiBut *but);
|
||||
extern bool ui_button_is_active(struct ARegion *ar);
|
||||
extern bool ui_button_is_active(struct ARegion *ar) ATTR_WARN_UNUSED_RESULT;
|
||||
extern int ui_button_open_menu_direction(uiBut *but);
|
||||
extern void ui_button_text_password_hide(char password_str[UI_MAX_DRAW_STR], uiBut *but, const bool restore);
|
||||
void ui_button_clipboard_free(void);
|
||||
|
@ -562,7 +563,7 @@ void ui_resources_free(void);
|
|||
|
||||
/* interface_layout.c */
|
||||
void ui_layout_add_but(uiLayout *layout, uiBut *but);
|
||||
int ui_but_can_align(uiBut *but);
|
||||
bool ui_but_can_align(uiBut *but) ATTR_WARN_UNUSED_RESULT;
|
||||
void ui_but_add_search(uiBut *but, PointerRNA *ptr, PropertyRNA *prop, PointerRNA *searchptr, PropertyRNA *searchprop);
|
||||
void ui_but_add_shortcut(uiBut *but, const char *key_str, const bool do_strip);
|
||||
void ui_layout_list_set_labels_active(uiLayout *layout);
|
||||
|
@ -578,9 +579,9 @@ void ui_but_anim_copy_driver(struct bContext *C);
|
|||
void ui_but_anim_paste_driver(struct bContext *C);
|
||||
void ui_but_anim_add_keyingset(struct bContext *C);
|
||||
void ui_but_anim_remove_keyingset(struct bContext *C);
|
||||
int ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen);
|
||||
int ui_but_anim_expression_set(uiBut *but, const char *str);
|
||||
int ui_but_anim_expression_create(uiBut *but, const char *str);
|
||||
bool ui_but_anim_expression_get(uiBut *but, char *str, size_t maxlen);
|
||||
bool ui_but_anim_expression_set(uiBut *but, const char *str);
|
||||
bool ui_but_anim_expression_create(uiBut *but, const char *str);
|
||||
void ui_but_anim_autokey(struct bContext *C, uiBut *but, struct Scene *scene, float cfra);
|
||||
|
||||
/* interface_eyedropper.c */
|
||||
|
|
|
@ -1362,7 +1362,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB
|
|||
|
||||
/* menu item - add some more padding so menus don't feel cramped. it must
|
||||
* be part of the button so that this area is still clickable */
|
||||
if (but->block && ui_block_is_menu(but->block))
|
||||
if (ui_block_is_menu(but->block))
|
||||
rect->xmin += 0.3f * U.widget_unit;
|
||||
|
||||
widget_draw_icon(but, but->icon + but->iconadd, alpha, rect, show_menu_icon);
|
||||
|
|
Loading…
Reference in New Issue