Blender  V2.93
Variables
ed_undo.c File Reference
#include <string.h>
#include "MEM_guardedalloc.h"
#include "CLG_log.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "BLT_translation.h"
#include "BKE_blender_undo.h"
#include "BKE_callbacks.h"
#include "BKE_context.h"
#include "BKE_global.h"
#include "BKE_layer.h"
#include "BKE_main.h"
#include "BKE_paint.h"
#include "BKE_report.h"
#include "BKE_scene.h"
#include "BKE_screen.h"
#include "BKE_undo_system.h"
#include "BKE_workspace.h"
#include "BLO_blend_validate.h"
#include "ED_gpencil.h"
#include "ED_object.h"
#include "ED_outliner.h"
#include "ED_render.h"
#include "ED_screen.h"
#include "ED_undo.h"
#include "WM_api.h"
#include "WM_toolsystem.h"
#include "WM_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "UI_interface.h"
#include "UI_resources.h"

Go to the source code of this file.

Functions

Generic Undo System Access

Non-operator undo editor functions.

bool ED_undo_is_state_valid (bContext *C)
 
void ED_undo_group_begin (bContext *C)
 
void ED_undo_group_end (bContext *C)
 
void ED_undo_push (bContext *C, const char *str)
 
static void ed_undo_step_pre (bContext *C, wmWindowManager *wm, const enum eUndoStepDir undo_dir, ReportList *reports)
 
static void ed_undo_step_post (bContext *C, wmWindowManager *wm, const enum eUndoStepDir undo_dir, ReportList *reports)
 
static int ed_undo_step_direction (bContext *C, enum eUndoStepDir step, ReportList *reports)
 
static int ed_undo_step_by_name (bContext *C, const char *undo_name, ReportList *reports)
 
static int ed_undo_step_by_index (bContext *C, const int undo_index, ReportList *reports)
 
void ED_undo_grouped_push (bContext *C, const char *str)
 
void ED_undo_pop (bContext *C)
 
void ED_undo_redo (bContext *C)
 
void ED_undo_push_op (bContext *C, wmOperator *op)
 
void ED_undo_grouped_push_op (bContext *C, wmOperator *op)
 
void ED_undo_pop_op (bContext *C, wmOperator *op)
 
bool ED_undo_is_valid (const bContext *C, const char *undoname)
 
bool ED_undo_is_memfile_compatible (const bContext *C)
 
bool ED_undo_is_legacy_compatible_for_property (struct bContext *C, ID *id)
 
UndoStackED_undo_stack_get (void)
 
Undo, Undo Push & Redo Operators
static int ed_undo_exec (bContext *C, wmOperator *op)
 
static int ed_undo_push_exec (bContext *C, wmOperator *op)
 
static int ed_redo_exec (bContext *C, wmOperator *op)
 
static int ed_undo_redo_exec (bContext *C, wmOperator *UNUSED(op))
 
static bool ed_undo_is_init_poll (bContext *C)
 
static bool ed_undo_is_init_and_screenactive_poll (bContext *C)
 
static bool ed_undo_redo_poll (bContext *C)
 
static bool ed_undo_poll (bContext *C)
 
void ED_OT_undo (wmOperatorType *ot)
 
void ED_OT_undo_push (wmOperatorType *ot)
 
static bool ed_redo_poll (bContext *C)
 
void ED_OT_redo (wmOperatorType *ot)
 
void ED_OT_undo_redo (wmOperatorType *ot)
 
Operator Repeat
int ED_undo_operator_repeat (bContext *C, wmOperator *op)
 
void ED_undo_operator_repeat_cb (bContext *C, void *arg_op, void *UNUSED(arg_unused))
 
void ED_undo_operator_repeat_cb_evt (bContext *C, void *arg_op, int UNUSED(arg_unused))
 
Undo History Operator
static const EnumPropertyItemrna_undo_itemf (bContext *C, int *totitem)
 
static int undo_history_invoke (bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
 
static int undo_history_exec (bContext *C, wmOperator *op)
 
static bool undo_history_poll (bContext *C)
 
void ED_OT_undo_history (wmOperatorType *ot)
 
Undo Helper Functions
void ED_undo_object_set_active_or_warn (Scene *scene, ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log)
 
void ED_undo_object_editmode_restore_helper (struct bContext *C, Object **object_array, uint object_array_len, uint object_array_stride)
 
Undo View Layer Helper Functions

Needed because view layer functions such as BKE_view_layer_array_from_objects_in_edit_mode_unique_data also check visibility, which is not reliable when it comes to object undo operations, since hidden objects can be operated on in the properties editor, and local collections may be used.

static int undo_editmode_objects_from_view_layer_prepare (ViewLayer *view_layer, Object *obact)
 
Object ** ED_undo_editmode_objects_from_view_layer (ViewLayer *view_layer, uint *r_len)
 
Base ** ED_undo_editmode_bases_from_view_layer (ViewLayer *view_layer, uint *r_len)
 

Variables

static CLG_LogRef LOG = {"ed.undo"}
 

Function Documentation

◆ ED_OT_redo()

void ED_OT_redo ( wmOperatorType ot)

◆ ED_OT_undo()

void ED_OT_undo ( wmOperatorType ot)

◆ ED_OT_undo_history()

void ED_OT_undo_history ( wmOperatorType ot)

◆ ED_OT_undo_push()

void ED_OT_undo_push ( wmOperatorType ot)

◆ ED_OT_undo_redo()

void ED_OT_undo_redo ( wmOperatorType ot)

◆ ed_redo_exec()

static int ed_redo_exec ( bContext C,
wmOperator op 
)
static

◆ ed_redo_poll()

static bool ed_redo_poll ( bContext C)
static

◆ ED_undo_editmode_bases_from_view_layer()

Base** ED_undo_editmode_bases_from_view_layer ( ViewLayer view_layer,
uint r_len 
)

◆ ED_undo_editmode_objects_from_view_layer()

Object** ED_undo_editmode_objects_from_view_layer ( ViewLayer view_layer,
uint r_len 
)

◆ ed_undo_exec()

static int ed_undo_exec ( bContext C,
wmOperator op 
)
static

◆ ED_undo_group_begin()

void ED_undo_group_begin ( bContext C)

◆ ED_undo_group_end()

void ED_undo_group_end ( bContext C)

◆ ED_undo_grouped_push()

void ED_undo_grouped_push ( bContext C,
const char *  str 
)

◆ ED_undo_grouped_push_op()

void ED_undo_grouped_push_op ( bContext C,
wmOperator op 
)

◆ ed_undo_is_init_and_screenactive_poll()

static bool ed_undo_is_init_and_screenactive_poll ( bContext C)
static

◆ ed_undo_is_init_poll()

static bool ed_undo_is_init_poll ( bContext C)
static

◆ ED_undo_is_legacy_compatible_for_property()

bool ED_undo_is_legacy_compatible_for_property ( struct bContext C,
ID id 
)

When a property of ID changes, return false.

This is to avoid changes to a property making undo pushes which are ignored by the undo-system. For example, changing a brush property isn't stored by sculpt-mode undo steps. This workaround is needed until the limitation is removed, see: T61948.

Definition at line 469 of file ed_undo.c.

References C, CLOG_INFO, CTX_data_view_layer(), Object::data, GS, id, LOG, Object::mode, ID::name, NULL, OB_MODE_ALL_PAINT, OB_MODE_EDIT, and OBACT.

Referenced by radial_control_modal(), and ui_apply_but_undo().

◆ ED_undo_is_memfile_compatible()

bool ED_undo_is_memfile_compatible ( const bContext C)

Definition at line 445 of file ed_undo.c.

References C, CTX_data_view_layer(), Object::mode, NULL, OB_MODE_EDIT, and OBACT.

◆ ED_undo_is_state_valid()

bool ED_undo_is_state_valid ( bContext C)

Run from the main event loop, basic checks that undo is left in a correct state.

Definition at line 82 of file ed_undo.c.

References C, CTX_wm_manager(), UndoStack::group_level, NULL, UndoStep::skip, UndoStack::step_active, and wmWindowManager::undo_stack.

Referenced by wm_event_do_handlers().

◆ ED_undo_is_valid()

bool ED_undo_is_valid ( const bContext C,
const char *  undoname 
)

◆ ED_undo_object_editmode_restore_helper()

void ED_undo_object_editmode_restore_helper ( struct bContext C,
Object **  object_array,
uint  object_array_len,
uint  object_array_stride 
)

◆ ED_undo_object_set_active_or_warn()

void ED_undo_object_set_active_or_warn ( Scene scene,
ViewLayer view_layer,
Object ob,
const char *  info,
CLG_LogRef log 
)

◆ ED_undo_operator_repeat()

int ED_undo_operator_repeat ( bContext C,
wmOperator op 
)

◆ ED_undo_operator_repeat_cb()

void ED_undo_operator_repeat_cb ( bContext C,
void *  arg_op,
void *  UNUSEDarg_unused 
)

Definition at line 749 of file ed_undo.c.

References C, and ED_undo_operator_repeat().

◆ ED_undo_operator_repeat_cb_evt()

void ED_undo_operator_repeat_cb_evt ( bContext C,
void *  arg_op,
int   UNUSEDarg_unused 
)

Definition at line 754 of file ed_undo.c.

References C, and ED_undo_operator_repeat().

◆ ed_undo_poll()

static bool ed_undo_poll ( bContext C)
static

◆ ED_undo_pop()

void ED_undo_pop ( bContext C)

Definition at line 407 of file ed_undo.c.

References C, ed_undo_step_direction(), NULL, and STEP_UNDO.

Referenced by redraw_timer_step().

◆ ED_undo_pop_op()

void ED_undo_pop_op ( bContext C,
wmOperator op 
)

◆ ED_undo_push()

void ED_undo_push ( bContext C,
const char *  str 
)

Definition at line 117 of file ed_undo.c.

References BKE_undosys_print(), BKE_undosys_stack_limit_steps_and_memory(), BKE_undosys_step_push(), C, CLOG_CHECK, CLOG_INFO, CTX_wm_manager(), G, LOG, memory_limit, NC_WM, ND_LIB_OVERRIDE_CHANGED, UndoStep::next, NULL, UndoStack::step_active, UndoStack::step_init, steps, str, UNDO_PUSH_RET_OVERRIDE_CHANGED, wmWindowManager::undo_stack, WM_file_tag_modified(), and WM_main_add_notifier().

Referenced by attribute_search_exec_fn(), colorband_add_cb(), colorband_del_cb(), colorband_distribute_cb(), colorband_flip_cb(), colorband_tools_dofunc(), curvemap_tools_dofunc(), CurveProfile_presets_dofunc(), CurveProfile_tools_dofunc(), delete_fmodifier_cb(), do_outliner_item_editmode_toggle(), do_outliner_item_mode_toggle_generic(), do_outliner_item_posemode_toggle(), do_view3d_header_buttons(), driver_add_var_cb(), driver_delete_var_cb(), ED_sculpt_undo_push_multires_mesh_end(), ED_undo_grouped_push(), ed_undo_push_exec(), ED_undo_push_op(), eyedropper_add_material(), file_browse_exec(), fmodifier_reorder(), import_endjob(), object_transfer_mode_to_base(), outliner_action_set_exec(), outliner_animdata_operation_exec(), outliner_constraint_operation_exec(), outliner_data_operation_exec(), outliner_id_operation_exec(), outliner_lib_operation_exec(), outliner_modifier_operation_exec(), outliner_object_operation_exec(), outliner_scene_operation_exec(), radial_control_modal(), template_id_cb(), text_autocomplete_invoke(), text_autocomplete_modal(), ui_apply_but_funcs_after(), and ui_node_link().

◆ ed_undo_push_exec()

static int ed_undo_push_exec ( bContext C,
wmOperator op 
)
static

◆ ED_undo_push_op()

void ED_undo_push_op ( bContext C,
wmOperator op 
)

◆ ED_undo_redo()

void ED_undo_redo ( bContext C)

Definition at line 411 of file ed_undo.c.

References C, ed_undo_step_direction(), NULL, and STEP_REDO.

Referenced by ED_undo_operator_repeat(), and redraw_timer_step().

◆ ed_undo_redo_exec()

static int ed_undo_redo_exec ( bContext C,
wmOperator UNUSEDop 
)
static

◆ ed_undo_redo_poll()

static bool ed_undo_redo_poll ( bContext C)
static

◆ ED_undo_stack_get()

UndoStack* ED_undo_stack_get ( void  )

◆ ed_undo_step_by_index()

static int ed_undo_step_by_index ( bContext C,
const int  undo_index,
ReportList reports 
)
static

Load the step matching given index in the stack. May undo or redo several steps at once. The target step will be the one indicated by the given index.

Definition at line 366 of file ed_undo.c.

References BKE_undosys_step_load_from_index(), BLI_assert, BLI_findindex(), C, CLOG_INFO, CTX_wm_manager(), ED_gpencil_session_active(), ed_undo_step_post(), ed_undo_step_pre(), LOG, OPERATOR_FINISHED, UndoStack::step_active, STEP_REDO, STEP_UNDO, UndoStack::steps, and wmWindowManager::undo_stack.

Referenced by undo_history_exec().

◆ ed_undo_step_by_name()

static int ed_undo_step_by_name ( bContext C,
const char *  undo_name,
ReportList reports 
)
static

Undo the step matching given name. May undo several steps at once. The target step will be the one immediately before given named one.

Definition at line 318 of file ed_undo.c.

References BKE_undosys_step_calc_direction(), BKE_undosys_step_find_by_name(), BKE_undosys_step_load_data_ex(), BLI_assert, C, CLOG_ERROR, CLOG_INFO, CTX_wm_manager(), ED_gpencil_session_active(), ed_undo_step_post(), ed_undo_step_pre(), ELEM, LOG, NULL, OPERATOR_CANCELLED, OPERATOR_FINISHED, UndoStep::prev, STEP_REDO, STEP_UNDO, and wmWindowManager::undo_stack.

Referenced by ED_undo_pop_op().

◆ ed_undo_step_direction()

static int ed_undo_step_direction ( bContext C,
enum eUndoStepDir  step,
ReportList reports 
)
static

Undo or redo one step from current active one. May undo or redo several steps at once only if the target step is a 'skipped' one. The target step will be the one immediately before or after the active one.

Definition at line 281 of file ed_undo.c.

References BKE_undosys_step_redo(), BKE_undosys_step_undo(), BLI_assert, C, CLOG_INFO, CTX_wm_manager(), ED_gpencil_session_active(), ED_undo_gpencil_step(), ed_undo_step_post(), ed_undo_step_pre(), ELEM, LOG, OPERATOR_FINISHED, STEP_REDO, STEP_UNDO, and wmWindowManager::undo_stack.

Referenced by ed_redo_exec(), ed_undo_exec(), ED_undo_pop(), and ED_undo_redo().

◆ ed_undo_step_post()

static void ed_undo_step_post ( bContext C,
wmWindowManager wm,
const enum eUndoStepDir  undo_dir,
ReportList reports 
)
static

◆ ed_undo_step_pre()

static void ed_undo_step_pre ( bContext C,
wmWindowManager wm,
const enum eUndoStepDir  undo_dir,
ReportList reports 
)
static

◆ rna_undo_itemf()

static const EnumPropertyItem* rna_undo_itemf ( bContext C,
int *  totitem 
)
static

◆ undo_editmode_objects_from_view_layer_prepare()

static int undo_editmode_objects_from_view_layer_prepare ( ViewLayer view_layer,
Object obact 
)
static

◆ undo_history_exec()

static int undo_history_exec ( bContext C,
wmOperator op 
)
static

◆ undo_history_invoke()

static int undo_history_invoke ( bContext C,
wmOperator op,
const wmEvent UNUSEDevent 
)
static

◆ undo_history_poll()

static bool undo_history_poll ( bContext C)
static

Variable Documentation

◆ LOG

CLG_LogRef LOG = {"ed.undo"}
static