Fix flipped order of items in the "Undo History" menu

Error in 0e1bb232e6.
This commit is contained in:
Campbell Barton 2022-01-19 13:20:35 +11:00
parent 2e5aecf557
commit 7e3b1e2c8f
Notes: blender-bot 2023-07-10 10:12:37 +02:00
Referenced by issue #95024, Undo History item order is reversed
1 changed files with 8 additions and 3 deletions

View File

@ -243,8 +243,11 @@ static void undo_history_draw_menu(const bContext *C, Menu *menu)
if (wm->undo_stack == NULL) {
return;
}
int undo_step_count = 0;
for (UndoStep *us = wm->undo_stack->steps.first; us; us = us->next) {
int undo_step_count_all = 0;
for (UndoStep *us = wm->undo_stack->steps.last; us; us = us->prev) {
undo_step_count_all += 1;
if (us->skip) {
continue;
}
@ -255,10 +258,12 @@ static void undo_history_draw_menu(const bContext *C, Menu *menu)
uiLayout *column = NULL;
const int col_size = 20 + (undo_step_count / 12);
int i = 0;
undo_step_count = 0;
for (UndoStep *us = wm->undo_stack->steps.first; us; us = us->next, i++) {
/* Reverse the order so the most recent state is first in the menu. */
int i = undo_step_count_all - 1;
for (UndoStep *us = wm->undo_stack->steps.last; us; us = us->prev, i--) {
if (us->skip) {
continue;
}