User Interface: fix for crash pressing Ctrl+Delete
also remove redundant string duplication.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user