[Bf-blender-cvs] [02aec1e] master: User Interface: fix for crash pressing Ctrl+Delete

Campbell Barton noreply at git.blender.org
Mon Dec 2 11:36:51 CET 2013


Commit: 02aec1e758732a8a307b552b464da2fef3865f7b
Author: Campbell Barton
Date:   Mon Dec 2 21:35:42 2013 +1100
http://developer.blender.org/rB02aec1e758732a8a307b552b464da2fef3865f7b

User Interface: fix for crash pressing Ctrl+Delete

also remove redundant string duplication.

===================================================================

M	source/blender/editors/interface/interface_handlers.c
M	source/blender/editors/interface/interface_widgets.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 1ed0c12..d0b0661 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -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;
 		}
 	}
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c
index 27f16a6..0621334 100644
--- a/source/blender/editors/interface/interface_widgets.c
+++ b/source/blender/editors/interface/interface_widgets.c
@@ -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) {




More information about the Bf-blender-cvs mailing list