Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-12-11 13:33:17 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-12-11 13:35:28 +0400
commit8e94d3685a7a421282f031725b8d8ae39a10a30b (patch)
treebc9182aef89d5b5d452e4d4bb2331505a909406a /source
parentc0b717b046804022bd0c3b45ffadf285746563ee (diff)
Interface: avoid setting \0 to drawstr in widget_draw_text
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/interface/interface_style.c2
-rw-r--r--source/blender/editors/interface/interface_widgets.c20
2 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c
index 67a686d0ee4..f9595edf616 100644
--- a/source/blender/editors/interface/interface_style.c
+++ b/source/blender/editors/interface/interface_style.c
@@ -179,7 +179,7 @@ void uiStyleFontDrawExt(uiFontStyle *fs, const rcti *rect, const char *str,
if (fs->kerning == 1)
BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
- BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
+ BLF_draw(fs->uifont_id, str, len);
BLF_disable(fs->uifont_id, BLF_CLIPPING);
if (fs->shadow)
BLF_disable(fs->uifont_id, BLF_SHADOW);
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 8debc4098fa..d353983ff70 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -1122,8 +1122,8 @@ static void ui_text_clip_right_label(uiFontStyle *fstyle, uiBut *but, const rcti
static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect)
{
- //int transopts; // UNUSED
- char *cpoin = NULL;
+ int drawstr_left_len = UI_MAX_DRAW_STR;
+ char *drawstr_right = NULL;
/* for underline drawing */
float font_xofs, font_yofs;
@@ -1190,21 +1190,24 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
/* cut string in 2 parts - only for menu entries */
if ((but->block->flag & UI_BLOCK_LOOP)) {
if (ELEM3(but->type, NUM, TEX, NUMSLI) == 0) {
- cpoin = strchr(but->drawstr, UI_SEP_CHAR);
- if (cpoin) *cpoin = 0;
+ drawstr_right = strchr(but->drawstr, UI_SEP_CHAR);
+ if (drawstr_right) {
+ drawstr_left_len = (drawstr_right - but->drawstr);
+ drawstr_right++;
+ }
}
}
glColor4ubv((unsigned char *)wcol->text);
uiStyleFontDrawExt(fstyle, rect, but->drawstr + but->ofs,
- sizeof(but->drawstr) - but->ofs, &font_xofs, &font_yofs);
+ drawstr_left_len - but->ofs, &font_xofs, &font_yofs);
if (but->menu_key != '\0') {
char fixedbuf[128];
char *str;
- BLI_strncpy(fixedbuf, but->drawstr + but->ofs, sizeof(fixedbuf));
+ BLI_strncpy(fixedbuf, but->drawstr + but->ofs, min_ii(sizeof(fixedbuf), drawstr_left_len));
str = strchr(fixedbuf, but->menu_key - 32); /* upper case */
if (str == NULL)
@@ -1233,11 +1236,10 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b
}
/* part text right aligned */
- if (cpoin) {
+ if (drawstr_right) {
fstyle->align = UI_STYLE_TEXT_RIGHT;
rect->xmax -= ui_but_draw_menu_icon(but) ? UI_DPI_ICON_SIZE : 0.25f * U.widget_unit;
- uiStyleFontDraw(fstyle, rect, cpoin + 1);
- *cpoin = UI_SEP_CHAR;
+ uiStyleFontDraw(fstyle, rect, drawstr_right);
}
}