From a0eb54142f244641041b0cb317cd09171105ad72 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 3 Apr 2018 08:35:42 +0200 Subject: Undo: replace global access w/ ED_undo_stack_get While I'd like to avoid using this too much since the operator system should handle. It's less trouble than accessing it inline each time. --- source/blender/editors/undo/ed_undo.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'source/blender/editors/undo') diff --git a/source/blender/editors/undo/ed_undo.c b/source/blender/editors/undo/ed_undo.c index 691ba066bf9..4f62e38dc0b 100644 --- a/source/blender/editors/undo/ed_undo.c +++ b/source/blender/editors/undo/ed_undo.c @@ -42,6 +42,7 @@ #include "BKE_blender_undo.h" #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_main.h" #include "BKE_screen.h" #include "BKE_undo_system.h" @@ -190,6 +191,19 @@ bool ED_undo_is_valid(const bContext *C, const char *undoname) return BKE_undosys_stack_has_undo(wm->undo_stack, undoname); } +/** + * Ideally we wont access the stack directly, + * this is needed for modes which handle undo themselves (bypassing #ED_undo_push). + * + * Using global isn't great, this just avoids doing inline, + * causing 'BKE_global.h' & 'BKE_main.h' includes. + */ +UndoStack *ED_undo_stack_get(void) +{ + wmWindowManager *wm = G.main->wm.first; + return wm->undo_stack; +} + /** \} */ /* -------------------------------------------------------------------- */ -- cgit v1.2.3