User Interface: fix for crash pressing Ctrl+Delete

also remove redundant string duplication.
This commit is contained in:
2013-12-02 21:35:42 +11:00
parent 1815225faa
commit 02aec1e758
2 changed files with 2 additions and 6 deletions

View File

@@ -1896,7 +1896,7 @@ static bool ui_textedit_delete(uiBut *but, uiHandleButtonData *data, int directi
int step;
BLI_str_cursor_step_utf8(str, len, &pos, direction, jump, true);
step = pos - but->pos;
memmove(&str[but->pos], &str[but->pos + step], (len + 1) - but->pos);
memmove(&str[but->pos], &str[but->pos + step], (len + 1) - (but->pos + step));
changed = true;
}
}

View File

@@ -1008,13 +1008,9 @@ static void ui_text_clip_cursor(uiFontStyle *fstyle, uiBut *but, const rcti *rec
while (but->strwidth > okwidth) {
float width;
char buf[UI_MAX_DRAW_STR];
/* copy draw string */
BLI_strncpy_utf8(buf, but->drawstr, sizeof(buf));
/* string position of cursor */
buf[but->pos] = 0;
width = BLF_width(fstyle->uifont_id, buf + but->ofs, sizeof(buf) - but->ofs);
width = BLF_width(fstyle->uifont_id, but->drawstr + but->ofs, but->pos - but->ofs);
/* if cursor is at 20 pixels of right side button we clip left */
if (width > okwidth - 20) {