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.
This commit is contained in:
parent
31f2a6755d
commit
a0eb54142f
|
@ -51,6 +51,8 @@ void ED_undo_operator_repeat_cb_evt(struct bContext *C, void *arg_op, int arg
|
|||
|
||||
bool ED_undo_is_valid(const struct bContext *C, const char *undoname);
|
||||
|
||||
struct UndoStack *ED_undo_stack_get(void);
|
||||
|
||||
/* undo_system_types.c */
|
||||
void ED_undosys_type_init(void);
|
||||
void ED_undosys_type_free(void);
|
||||
|
|
|
@ -45,16 +45,15 @@
|
|||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_particle.h"
|
||||
#include "BKE_pointcache.h"
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_undo_system.h"
|
||||
|
||||
#include "ED_object.h"
|
||||
#include "ED_particle.h"
|
||||
#include "ED_physics.h"
|
||||
#include "ED_undo.h"
|
||||
|
||||
#include "particle_edit_utildefines.h"
|
||||
|
||||
|
@ -304,10 +303,10 @@ void ED_particle_undosys_type(UndoType *ut)
|
|||
|
||||
void PE_undo_push(struct Scene *scene, const char *str)
|
||||
{
|
||||
wmWindowManager *wm = G.main->wm.first;
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
bContext *C_temp = CTX_create();
|
||||
CTX_data_scene_set(C_temp, scene);
|
||||
BKE_undosys_step_push_with_type(wm->undo_stack, C_temp, str, BKE_UNDOSYS_TYPE_PARTICLE);
|
||||
BKE_undosys_step_push_with_type(ustack, C_temp, str, BKE_UNDOSYS_TYPE_PARTICLE);
|
||||
CTX_free(C_temp);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,10 @@
|
|||
|
||||
#include "BKE_context.h"
|
||||
#include "BKE_paint.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_undo_system.h"
|
||||
|
||||
#include "ED_paint.h"
|
||||
#include "ED_undo.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
#include "WM_types.h"
|
||||
|
@ -155,15 +154,15 @@ void ED_paintcurve_undosys_type(UndoType *ut)
|
|||
|
||||
void ED_paintcurve_undo_push_begin(const char *name)
|
||||
{
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
bContext *C = NULL; /* special case, we never read from this. */
|
||||
wmWindowManager *wm = G.main->wm.first;
|
||||
BKE_undosys_step_push_init_with_type(wm->undo_stack, C, name, BKE_UNDOSYS_TYPE_PAINTCURVE);
|
||||
BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_PAINTCURVE);
|
||||
}
|
||||
|
||||
void ED_paintcurve_undo_push_end(void)
|
||||
{
|
||||
wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */
|
||||
BKE_undosys_step_push(wm->undo_stack, NULL, NULL);
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
BKE_undosys_step_push(ustack, NULL, NULL);
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
|
|
@ -41,10 +41,10 @@
|
|||
#include "BKE_depsgraph.h"
|
||||
#include "BKE_image.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_undo_system.h"
|
||||
|
||||
#include "ED_paint.h"
|
||||
#include "ED_undo.h"
|
||||
|
||||
#include "GPU_draw.h"
|
||||
|
||||
|
@ -358,15 +358,15 @@ static void image_undo_free_list(ListBase *lb)
|
|||
|
||||
void ED_image_undo_push_begin(const char *name)
|
||||
{
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
bContext *C = NULL; /* special case, we never read from this. */
|
||||
wmWindowManager *wm = G.main->wm.first;
|
||||
BKE_undosys_step_push_init_with_type(wm->undo_stack, C, name, BKE_UNDOSYS_TYPE_IMAGE);
|
||||
BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_IMAGE);
|
||||
}
|
||||
|
||||
void ED_image_undo_push_end(void)
|
||||
{
|
||||
wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */
|
||||
BKE_undosys_step_push(wm->undo_stack, NULL, NULL);
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
BKE_undosys_step_push(ustack, NULL, NULL);
|
||||
}
|
||||
|
||||
static void image_undo_invalidate(void)
|
||||
|
@ -486,8 +486,8 @@ ListBase *ED_image_undosys_step_get_tiles(UndoStep *us_p)
|
|||
|
||||
ListBase *ED_image_undo_get_tiles(void)
|
||||
{
|
||||
wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */
|
||||
UndoStep *us = BKE_undosys_stack_init_or_active_with_type(wm->undo_stack, BKE_UNDOSYS_TYPE_IMAGE);
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
UndoStep *us = BKE_undosys_stack_init_or_active_with_type(ustack, BKE_UNDOSYS_TYPE_IMAGE);
|
||||
return ED_image_undosys_step_get_tiles(us);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,8 +59,6 @@
|
|||
#include "BKE_key.h"
|
||||
#include "BKE_mesh.h"
|
||||
#include "BKE_subsurf.h"
|
||||
#include "BKE_global.h"
|
||||
#include "BKE_main.h"
|
||||
#include "BKE_undo_system.h"
|
||||
|
||||
#include "WM_api.h"
|
||||
|
@ -71,6 +69,7 @@
|
|||
#include "ED_paint.h"
|
||||
#include "ED_object.h"
|
||||
#include "ED_sculpt.h"
|
||||
#include "ED_undo.h"
|
||||
|
||||
#include "bmesh.h"
|
||||
#include "paint_intern.h"
|
||||
|
@ -974,9 +973,9 @@ SculptUndoNode *sculpt_undo_push_node(
|
|||
|
||||
void sculpt_undo_push_begin(const char *name)
|
||||
{
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
bContext *C = NULL; /* special case, we never read from this. */
|
||||
wmWindowManager *wm = G.main->wm.first;
|
||||
BKE_undosys_step_push_init_with_type(wm->undo_stack, C, name, BKE_UNDOSYS_TYPE_SCULPT);
|
||||
BKE_undosys_step_push_init_with_type(ustack, C, name, BKE_UNDOSYS_TYPE_SCULPT);
|
||||
}
|
||||
|
||||
void sculpt_undo_push_end(void)
|
||||
|
@ -995,8 +994,8 @@ void sculpt_undo_push_end(void)
|
|||
BKE_pbvh_node_layer_disp_free(unode->node);
|
||||
}
|
||||
|
||||
wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */
|
||||
BKE_undosys_step_push(wm->undo_stack, NULL, NULL);
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
BKE_undosys_step_push(ustack, NULL, NULL);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
@ -1083,8 +1082,8 @@ static UndoSculpt *sculpt_undosys_step_get_nodes(UndoStep *us_p)
|
|||
|
||||
static UndoSculpt *sculpt_undo_get_nodes(void)
|
||||
{
|
||||
wmWindowManager *wm = G.main->wm.first; /* XXX, avoids adding extra arg. */
|
||||
UndoStep *us = BKE_undosys_stack_init_or_active_with_type(wm->undo_stack, BKE_UNDOSYS_TYPE_SCULPT);
|
||||
UndoStack *ustack = ED_undo_stack_get();
|
||||
UndoStep *us = BKE_undosys_stack_init_or_active_with_type(ustack, BKE_UNDOSYS_TYPE_SCULPT);
|
||||
return sculpt_undosys_step_get_nodes(us);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/** \} */
|
||||
|
||||
/* -------------------------------------------------------------------- */
|
||||
|
|
Loading…
Reference in New Issue