bugfix [#25577] Ctrl-Z after adding Color Ramp key resets ramp.

buttons would not add an undo event if the button had no tooltip/draw-string.

 add a fallback string 'Unknown Action' so undo's are predictable.
This commit is contained in:
Campbell Barton 2011-01-11 03:22:37 +00:00
parent 22577d98c9
commit 1b9c56c423

@ -326,18 +326,22 @@ static void ui_apply_autokey_undo(bContext *C, uiBut *but)
{
Scene *scene= CTX_data_scene(C);
uiAfterFunc *after;
const char *str= NULL;
if(but->flag & UI_BUT_UNDO) {
const char *str= NULL;
/* define which string to use for undo */
if ELEM(but->type, LINK, INLINK) str= "Add button link";
else if ELEM(but->type, MENU, ICONTEXTROW) str= but->drawstr;
else if(but->drawstr[0]) str= but->drawstr;
else str= but->tip;
}
/* delayed, after all other funcs run, popups are closed, etc */
if(str) {
/* fallback, else we dont get an undo! */
if(str == NULL || str[0] == '\0') {
str= "Unknown Action";
}
/* delayed, after all other funcs run, popups are closed, etc */
after= MEM_callocN(sizeof(uiAfterFunc), "uiAfterFunc");
BLI_strncpy(after->undostr, str, sizeof(after->undostr));
BLI_addtail(&UIAfterFuncs, after);