diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-11-18 07:13:26 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-11-18 07:13:26 +0300 |
commit | 8b8328fbfc63f9880c4a9100d83238555eaeec51 (patch) | |
tree | ba0279cae0612c84c24bbd5671b8ee403407e5b1 /source/blender/editors/interface/interface_handlers.c | |
parent | 80a701c4e6cbca59d445b9cf01b2c69dc8404738 (diff) | |
parent | 0688309988e546382748b9e755d84ae8a5059192 (diff) |
Merge branch 'blender-v2.91-release'
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index af71306cc3b..af671af94b2 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -171,7 +171,7 @@ static bool ui_mouse_motion_keynav_test(struct uiKeyNavLock *keynav, const wmEve /* pixels to move the cursor to get out of keyboard navigation */ #define BUTTON_KEYNAV_PX_LIMIT 8 -#define MENU_TOWARDS_MARGIN 20 /* margin in pixels */ +#define MENU_TOWARDS_MARGIN 20 /* margin in pixels */ #define MENU_TOWARDS_WIGGLE_ROOM 64 /* tolerance in pixels */ /* drag-lock distance threshold in pixels */ #define BUTTON_DRAGLOCK_THRESH 3 @@ -818,21 +818,25 @@ static void ui_apply_but_undo(uiBut *but) { if (but->flag & UI_BUT_UNDO) { const char *str = NULL; + size_t str_len_clip = SIZE_MAX - 1; bool skip_undo = false; /* define which string to use for undo */ if (but->type == UI_BTYPE_MENU) { str = but->drawstr; + str_len_clip = ui_but_drawstr_len_without_sep_char(but); } else if (but->drawstr[0]) { str = but->drawstr; + str_len_clip = ui_but_drawstr_len_without_sep_char(but); } else { str = but->tip; + str_len_clip = ui_but_tip_len_only_first_line(but); } /* fallback, else we don't get an undo! */ - if (str == NULL || str[0] == '\0') { + if (str == NULL || str[0] == '\0' || str_len_clip == 0) { str = "Unknown Action"; } @@ -869,7 +873,7 @@ static void ui_apply_but_undo(uiBut *but) /* delayed, after all other funcs run, popups are closed, etc */ uiAfterFunc *after = ui_afterfunc_new(); - BLI_strncpy(after->undostr, str, sizeof(after->undostr)); + BLI_strncpy(after->undostr, str, min_zz(str_len_clip + 1, sizeof(after->undostr))); } } |