68 if (wm->
runtime->undo_stack ==
nullptr) {
72 if (wm->
runtime->undo_stack->group_level != 0) {
76 if (wm->
runtime->undo_stack->step_active !=
nullptr) {
77 if (wm->
runtime->undo_stack->step_active->skip ==
true) {
104 int steps =
U.undosteps;
114 if ((steps <= 0) && wm->
runtime->undo_stack->step_init !=
nullptr) {
124 if (wm->
runtime->undo_stack ==
nullptr) {
132 if (wm->
runtime->undo_stack->step_active &&
133 (wm->
runtime->undo_stack->step_active->next ==
nullptr))
140 if (
U.undomemory != 0) {
141 const size_t memory_limit = size_t(
U.undomemory) * 1024 * 1024;
172 if (bmain->
lock !=
nullptr) {
174 reports,
RPT_DEBUG,
"Checking validity of current .blend file *BEFORE* undo step");
214 if (bmain->
lock !=
nullptr) {
215 BKE_report(reports,
RPT_INFO,
"Checking validity of current .blend file *AFTER* undo step");
274 if (undo_step_from_name ==
nullptr) {
275 CLOG_ERROR(&
LOG,
"Step name='%s' not found in current undo stack", undo_name);
281 if (undo_step_target ==
nullptr) {
282 CLOG_ERROR(&
LOG,
"Step name='%s' cannot be undone", undo_name);
288 wm->runtime->undo_stack, undo_step_target,
nullptr);
293 "Step name='%s', found direction=%s",
295 (undo_dir ==
STEP_UNDO) ?
"STEP_UNDO" :
"STEP_REDO");
316 const int active_step_index =
BLI_findindex(&
wm->runtime->undo_stack->steps,
317 wm->runtime->undo_stack->step_active);
318 if (undo_index == active_step_index) {
324 "Step index='%d', found direction=%s",
326 (undo_dir ==
STEP_UNDO) ?
"STEP_UNDO" :
"STEP_REDO");
341 const UndoStep *us =
wm->runtime->undo_stack->step_active;
393 if (view_layer !=
nullptr) {
396 if (obact !=
nullptr) {
417 if (view_layer !=
nullptr) {
420 if (obact !=
nullptr) {
429 if ((
id ==
nullptr) || (obact->
data ==
nullptr) ||
445 return wm->runtime->undo_stack;
486 if (
wm->runtime->undo_stack ==
nullptr) {
522 if (
wm->runtime->undo_stack ==
nullptr) {
527 "Undo disabled at startup in background-mode "
528 "(call `ed.undo_push()` to explicitly initialize the undo-system)");
562 ot->description =
"Undo previous action";
563 ot->idname =
"ED_OT_undo";
573 ot->name =
"Undo Push";
574 ot->description =
"Add an undo state (internal use only)";
575 ot->idname =
"ED_OT_undo_push";
586 "Add an undo step *function may be moved*",
605 ot->description =
"Redo previous action";
606 ot->idname =
"ED_OT_redo";
616 ot->name =
"Undo and Redo";
617 ot->description =
"Undo and redo previous action";
618 ot->idname =
"ED_OT_undo_redo";
633 bool success =
false;
648 ARegion *region_repeat = redo_region_from_hud ? redo_region_from_hud :
684 printf(
"redo_cb: operator redo failed: %s, return %d\n", op->
type->
name, retval);
694 printf(
"redo_cb: WM_operator_repeat_check returned false %s\n", op->
type->
name);
757 ot->name =
"Undo History";
758 ot->description =
"Redo specific action in history";
759 ot->idname =
"ED_OT_undo_history";
766 RNA_def_int(
ot->srna,
"item", 0, 0, INT_MAX,
"Item",
"", 0, INT_MAX);
783 if (base !=
nullptr) {
784 view_layer->
basact = base;
795 const Scene *scene_ref,
799 if (*scene_p == scene_ref) {
803 if (win->scene == scene_ref) {
804 *scene_p = win->scene;
814 uint object_array_len,
815 uint object_array_stride)
822 for (
Base *base : bases) {
825 Object **ob_p = object_array;
826 for (
uint i = 0;
i < object_array_len;
833 for (
Base *base : bases) {
834 const ID *
id =
static_cast<ID *
>(base->object->data);
865 const short object_type = baseact->
object->
type;
869 for (
Base *base = baseact,
872 base = base_next, base_next = base_next ? base_next->
next :
nullptr)
874 Object *ob = base->object;
876 if (object_data.
add(
static_cast<const ID *
>(ob->
data))) {
894 const short object_type = baseact->
object->
type;
901 base = base_next, base_next = base_next ? base_next->
next :
nullptr)
903 Object *ob = base->object;
905 if (object_data.
add(
static_cast<const ID *
>(ob->
data))) {
918 size_t total_memory = 0;
924 else if (us->data_size > 0) {
925 total_memory += us->data_size;
void BKE_callback_exec_id(Main *bmain, ID *id, eCbEvent evt)
ARegion * CTX_wm_region_popup(const bContext *C)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
ScrArea * CTX_wm_area(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
wmWindowManager * CTX_wm_manager(const bContext *C)
ViewLayer * CTX_data_view_layer(const bContext *C)
void BKE_view_layer_synced_ensure(const Scene *scene, ViewLayer *view_layer)
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
ListBase * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
void BKE_report(ReportList *reports, eReportType type, const char *message)
ARegion * BKE_area_find_region_active_win(const ScrArea *area)
void BKE_undosys_step_load_from_index(UndoStack *ustack, bContext *C, int index)
bool BKE_undosys_stack_has_undo(const UndoStack *ustack, const char *name)
const UndoType * BKE_UNDOSYS_TYPE_SCULPT
bool BKE_undosys_step_redo(UndoStack *ustack, bContext *C)
bool BKE_undosys_step_undo(UndoStack *ustack, bContext *C)
void BKE_undosys_stack_clear_active(UndoStack *ustack)
eUndoPushReturn BKE_undosys_step_push(UndoStack *ustack, bContext *C, const char *name)
eUndoStepDir BKE_undosys_step_calc_direction(const UndoStack *ustack, const UndoStep *us_target, const UndoStep *us_reference)
void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size_t memory_limit)
UndoStep * BKE_undosys_step_find_by_name(UndoStack *ustack, const char *name)
bool BKE_undosys_step_load_data_ex(UndoStack *ustack, bContext *C, UndoStep *us_target, UndoStep *us_reference, bool use_skip)
@ UNDO_PUSH_RET_OVERRIDE_CHANGED
void BKE_undosys_stack_group_end(UndoStack *ustack)
UndoStack * BKE_undosys_stack_create()
void BKE_undosys_print(UndoStack *ustack)
void BKE_undosys_stack_group_begin(UndoStack *ustack)
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
#define POINTER_OFFSET(v, ofs)
Utilities ensuring .blend file (i.e. Main) is in valid state during write and/or read process.
bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
#define CLOG_ERROR(clg_ref,...)
#define CLOG_DEBUG(clg_ref,...)
#define CLOG_WARN(clg_ref,...)
#define CLOG_CHECK(clg_ref, verbose_level,...)
#define CLOG_INFO(clg_ref,...)
#define ID_CHECK_UNDO(id)
#define OB_MODE_ALL_PAINT
Object is a sort of wrapper for general info.
void ED_outliner_select_sync_from_all_tag(bContext *C)
void ED_region_tag_refresh_ui(ARegion *region)
ARegion * ED_area_type_hud_redo_region_find(const ScrArea *area, const ARegion *hud_region)
bool ED_operator_screenactive(bContext *C)
#define ND_LIB_OVERRIDE_CHANGED
void append(const T &value)
void ED_undo_object_set_active_or_warn(Scene *scene, ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log)
void ED_undo_push(bContext *C, const char *str)
bool ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id, PointerRNA &ptr)
void ED_OT_redo(wmOperatorType *ot)
UndoStack * ED_undo_stack_get()
static wmOperatorStatus undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *)
static void ed_undo_step_pre(bContext *C, wmWindowManager *wm, const enum eUndoStepDir undo_dir, ReportList *reports)
void ED_undo_push_op(bContext *C, wmOperator *op)
void ED_undo_pop_op(bContext *C, wmOperator *op)
void ED_undo_group_begin(bContext *C)
size_t ED_undosys_total_memory_calc(UndoStack *ustack)
bool ED_undo_is_valid(const bContext *C, const char *undoname)
void ED_OT_undo_redo(wmOperatorType *ot)
void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int)
static int ed_undo_step_by_index(bContext *C, const int undo_index, ReportList *reports)
void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void *)
void ED_OT_undo_push(wmOperatorType *ot)
static wmOperatorStatus ed_undo_step_direction(bContext *C, enum eUndoStepDir step, ReportList *reports)
static void ed_undo_step_post(bContext *C, wmWindowManager *wm, const enum eUndoStepDir undo_dir, ReportList *reports)
static void ed_undo_refresh_for_op(bContext *C)
static wmOperatorStatus ed_undo_push_exec(bContext *C, wmOperator *op)
static wmOperatorStatus ed_undo_exec(bContext *C, wmOperator *op)
Vector< Object * > ED_undo_editmode_objects_from_view_layer(const Scene *scene, ViewLayer *view_layer)
static bool ed_redo_poll(bContext *C)
static bool ed_undo_is_init_poll(bContext *C)
static bool ed_undo_is_init_and_screenactive_poll(bContext *C)
static wmOperatorStatus ed_redo_exec(bContext *C, wmOperator *op)
static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *reports)
void ED_undo_redo(bContext *C)
static wmOperatorStatus ed_undo_redo_exec(bContext *C, wmOperator *)
bool ED_undo_is_state_valid(bContext *C)
static wmOperatorStatus undo_history_exec(bContext *C, wmOperator *op)
void ED_OT_undo(wmOperatorType *ot)
bool ED_undo_operator_repeat(bContext *C, wmOperator *op)
void ED_OT_undo_history(wmOperatorType *ot)
static bool ed_undo_poll(bContext *C)
void ED_undo_object_editmode_restore_helper(Scene *scene, ViewLayer *view_layer, Object **object_array, uint object_array_len, uint object_array_stride)
void ED_undo_grouped_push_op(bContext *C, wmOperator *op)
static bool ed_undo_redo_poll(bContext *C)
bool ED_undo_is_memfile_compatible(const bContext *C)
void ED_undo_pop(bContext *C)
void ED_undo_object_editmode_validate_scene_from_windows(wmWindowManager *wm, const Scene *scene_ref, Scene **scene_p, ViewLayer **view_layer_p)
void ED_undo_group_end(bContext *C)
void ED_undo_grouped_push(bContext *C, const char *str)
Vector< Base * > ED_undo_editmode_bases_from_view_layer(const Scene *scene, ViewLayer *view_layer)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void storage_tag_main_data_dirty()
void base_select(Base *base, eObjectSelect_Mode mode)
bool editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
void base_active_refresh(Main *bmain, Scene *scene, ViewLayer *view_layer)
bool editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
size_t step_memory_size_get(UndoStep *step)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
std::string RNA_string_get(PointerRNA *ptr, const char *name)
bool RNA_struct_undo_check(const StructRNA *type)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
bool(* check)(bContext *C, wmOperator *op)
struct ReportList * reports
struct wmOperatorType * type
WindowManagerRuntimeHandle * runtime
void WM_operator_stack_clear(wmWindowManager *wm)
void WM_operator_free_all_after(wmWindowManager *wm, wmOperator *op)
bool WM_operator_poll(bContext *C, wmOperatorType *ot)
bool WM_operator_repeat_check(const bContext *, wmOperator *op)
void WM_main_add_notifier(uint type, void *reference)
wmOperatorStatus WM_operator_repeat(bContext *C, wmOperator *op)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void WM_menu_name_call(bContext *C, const char *menu_name, blender::wm::OpCallContext context)
void WM_event_add_mousemove(wmWindow *win)
void WM_file_tag_modified()
void WM_jobs_kill_all(wmWindowManager *wm)
bool WM_jobs_test(const wmWindowManager *wm, const void *owner, int job_type)
bool WM_operator_check_ui_enabled(const bContext *C, const char *idname)
wmOperator * WM_operator_last_redo(const bContext *C)
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)