From 7e3b1e2c8f9f5d95692d37707506d790c5b503f7 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 19 Jan 2022 13:20:35 +1100 Subject: Fix flipped order of items in the "Undo History" menu Error in 0e1bb232e68ce71f4c3dd331ed6331665238a065. --- source/blender/editors/space_topbar/space_topbar.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'source/blender/editors/space_topbar') diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c index 7f0f30624cb..82a0de9b845 100644 --- a/source/blender/editors/space_topbar/space_topbar.c +++ b/source/blender/editors/space_topbar/space_topbar.c @@ -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; } -- cgit v1.2.3