From 535d27eb4923d5582ff16b4016344e8f712608d7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 11 Jan 2012 09:33:44 +0000 Subject: minor cleanup for string use - no functional changes - use more logical names for strings, noticed too many strings called `str` when reviewing name patch. - pass __func__ macro to uiBeginBlock(), quite a few names were wrong (copy/paste error). --- .../blender/editors/interface/interface_regions.c | 8 ++++---- .../blender/editors/interface/interface_templates.c | 21 +++++++++++---------- source/blender/editors/interface/view2d.c | 12 ++++++------ 3 files changed, 21 insertions(+), 20 deletions(-) (limited to 'source/blender/editors/interface') diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index c535f2c1ad0..973b43fca78 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -2109,7 +2109,7 @@ uiBlock *ui_block_func_COL(bContext *C, uiPopupBlockHandle *handle, void *arg_bu uiBut *but= arg_but; uiBlock *block; - block= uiBeginBlock(C, handle->region, "colorpicker", UI_EMBOSS); + block= uiBeginBlock(C, handle->region, __func__, UI_EMBOSS); if (but->rnaprop) { if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { @@ -2299,8 +2299,8 @@ uiPopupBlockHandle *ui_popup_menu_create(bContext *C, ARegion *butregion, uiBut uiStyle *style= UI_GetStyle(); uiPopupBlockHandle *handle; uiPopupMenu *pup; - pup= MEM_callocN(sizeof(uiPopupMenu), "menu dummy"); - pup->block= uiBeginBlock(C, NULL, "ui_button_menu_create", UI_EMBOSSP); + pup= MEM_callocN(sizeof(uiPopupMenu), __func__); + pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); pup->slideout= (but && (but->block->flag & UI_BLOCK_LOOP)); pup->but= but; @@ -2361,7 +2361,7 @@ uiPopupMenu *uiPupMenuBegin(bContext *C, const char *title, int icon) uiPopupMenu *pup= MEM_callocN(sizeof(uiPopupMenu), "popup menu"); uiBut *but; - pup->block= uiBeginBlock(C, NULL, "uiPupMenuBegin", UI_EMBOSSP); + pup->block= uiBeginBlock(C, NULL, __func__, UI_EMBOSSP); pup->block->flag |= UI_BLOCK_POPUP_MEMORY; pup->block->puphash= ui_popup_menu_hash(title); pup->layout= uiBlockLayout(pup->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_MENU, 0, 0, 200, 0, style); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 573b6cd0b08..ccca0c8f7cf 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -413,11 +413,11 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str } if(id->us > 1) { - char str[32]; + char numstr[32]; - BLI_snprintf(str, sizeof(str), "%d", id->us); + BLI_snprintf(numstr, sizeof(numstr), "%d", id->us); - but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0, + but= uiDefBut(block, BUT, 0, numstr, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Display number of users of this data (click to make a single-user copy)")); uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE)); @@ -1621,7 +1621,7 @@ static uiBlock *curvemap_clipping_func(bContext *C, struct ARegion *ar, void *cu uiBut *bt; float width= 8*UI_UNIT_X; - block= uiBeginBlock(C, ar, "curvemap_clipping_func", UI_EMBOSS); + block = uiBeginBlock(C, ar, __func__, UI_EMBOSS); /* use this for a fake extra empy space around the buttons */ uiDefBut(block, LABEL, 0, "", -4, 16, width+8, 6*UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); @@ -1680,7 +1680,7 @@ static uiBlock *curvemap_tools_func(bContext *C, struct ARegion *ar, void *cumap uiBlock *block; short yco= 0, menuwidth=10*UI_UNIT_X; - block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); @@ -1702,7 +1702,7 @@ static uiBlock *curvemap_brush_tools_func(bContext *C, struct ARegion *ar, void uiBlock *block; short yco= 0, menuwidth=10*UI_UNIT_X; - block= uiBeginBlock(C, ar, "curvemap_tools_func", UI_EMBOSS); + block= uiBeginBlock(C, ar, __func__, UI_EMBOSS); uiBlockSetButmFunc(block, curvemap_tools_dofunc, cumap_v); uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, IFACE_("Reset View"), 0, yco-=UI_UNIT_Y, menuwidth, UI_UNIT_Y, NULL, 0.0, 0.0, 0, 1, ""); @@ -2281,7 +2281,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * uiBlock *block; uiBut *but; Panel *pa; - char *name, str[32]; + const char *name; + char numstr[32]; int rnaicon=0, icon=0, i= 0, activei= 0, len= 0, items, found, min, max; /* validate arguments */ @@ -2372,7 +2373,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * uiItemL(row, (name)? name: "", icon); if(name) - MEM_freeN(name); + MEM_freeN((void *)name); } i++; @@ -2385,8 +2386,8 @@ void uiTemplateList(uiLayout *layout, bContext *C, PointerRNA *ptr, const char * uiItemL(row, "", ICON_NONE); /* next/prev button */ - BLI_snprintf(str, sizeof(str), "%d :", i); - but= uiDefIconTextButR_prop(block, NUM, 0, 0, str, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, ""); + BLI_snprintf(numstr, sizeof(numstr), "%d :", i); + but= uiDefIconTextButR_prop(block, NUM, 0, 0, numstr, 0,0,UI_UNIT_X*5,UI_UNIT_Y, activeptr, activeprop, 0, 0, 0, 0, 0, ""); if(i == 0) uiButSetFlag(but, UI_BUT_DISABLED); } diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 57d46de9cb7..81ea3370331 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1507,7 +1507,7 @@ View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short static void scroll_printstr(Scene *scene, float x, float y, float val, int power, short unit, char dir) { int len; - char str[32]; + char timecode_str[32]; /* adjust the scale unit to work ok */ if (dir == 'v') { @@ -1522,10 +1522,10 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power } /* get string to print */ - ANIM_timecode_string_from_frame(str, scene, power, (unit == V2D_UNIT_SECONDS), val); + ANIM_timecode_string_from_frame(timecode_str, scene, power, (unit == V2D_UNIT_SECONDS), val); /* get length of string, and adjust printing location to fit it into the horizontal scrollbar */ - len= strlen(str); + len= strlen(timecode_str); if (dir == 'h') { /* seconds/timecode display has slightly longer strings... */ if (unit == V2D_UNIT_SECONDS) @@ -1536,12 +1536,12 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power /* Add degree sympbol to end of string for vertical scrollbar? */ if ((dir == 'v') && (unit == V2D_UNIT_DEGREES)) { - str[len]= 186; - str[len+1]= 0; + timecode_str[len]= 186; + timecode_str[len+1]= 0; } /* draw it */ - BLF_draw_default_ascii(x, y, 0.0f, str, sizeof(str)-1); + BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str)-1); } /* Draw scrollbars in the given 2d-region */ -- cgit v1.2.3