Blender V5.0
ED_undo.hh File Reference
#include "BLI_sys_types.h"
#include "BLI_vector.hh"

Go to the source code of this file.

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)
void ED_undo_push_op (bContext *C, wmOperator *op)
void ED_undo_grouped_push (bContext *C, const char *str)
void ED_undo_grouped_push_op (bContext *C, wmOperator *op)
void ED_undo_pop_op (bContext *C, wmOperator *op)
void ED_undo_pop (bContext *C)
void ED_undo_redo (bContext *C)
void ED_OT_undo (wmOperatorType *ot)
void ED_OT_undo_push (wmOperatorType *ot)
void ED_OT_redo (wmOperatorType *ot)
void ED_OT_undo_redo (wmOperatorType *ot)
void ED_OT_undo_history (wmOperatorType *ot)
bool ED_undo_operator_repeat (bContext *C, wmOperator *op)
void ED_undo_operator_repeat_cb (bContext *C, void *arg_op, void *arg_unused)
void ED_undo_operator_repeat_cb_evt (bContext *C, void *arg_op, int arg_unused)
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 (bContext *C, ID *id, PointerRNA &ptr)
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_object_editmode_restore_helper (Scene *scene, ViewLayer *view_layer, Object **object_array, uint object_array_len, uint object_array_stride)
blender::Vector< Object * > ED_undo_editmode_objects_from_view_layer (const Scene *scene, ViewLayer *view_layer)
blender::Vector< Base * > ED_undo_editmode_bases_from_view_layer (const Scene *scene, ViewLayer *view_layer)
UndoStackED_undo_stack_get ()
void ED_undo_object_set_active_or_warn (Scene *scene, ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log)
void ED_undosys_type_init ()
void ED_undosys_type_free ()
MemFileED_undosys_stack_memfile_get_if_active (UndoStack *ustack)
void ED_undosys_stack_memfile_id_changed_tag (UndoStack *ustack, ID *id)
size_t ED_undosys_total_memory_calc (UndoStack *ustack)

Function Documentation

◆ ED_OT_redo()

void ED_OT_redo ( wmOperatorType * ot)

Definition at line 601 of file ed_undo.cc.

References ed_redo_exec(), ed_redo_poll(), and ot.

Referenced by ED_operatortypes_edutils().

◆ ED_OT_undo()

void ED_OT_undo ( wmOperatorType * ot)

Definition at line 558 of file ed_undo.cc.

References ed_undo_exec(), ed_undo_poll(), and ot.

Referenced by ED_operatortypes_edutils().

◆ 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)

Definition at line 613 of file ed_undo.cc.

References ed_undo_redo_exec(), ed_undo_redo_poll(), and ot.

Referenced by ED_operatortypes_edutils().

◆ ED_undo_editmode_bases_from_view_layer()

◆ ED_undo_editmode_objects_from_view_layer()

◆ ED_undo_group_begin()

◆ ED_undo_group_end()

◆ ED_undo_grouped_push()

◆ ED_undo_grouped_push_op()

void ED_undo_grouped_push_op ( bContext * C,
wmOperator * op )

◆ ED_undo_is_legacy_compatible_for_property()

bool ED_undo_is_legacy_compatible_for_property ( bContext * C,
ID * id,
PointerRNA & ptr )

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: #61948.

Definition at line 405 of file ed_undo.cc.

References BKE_view_layer_active_object_get(), BKE_view_layer_synced_ensure(), C, CLOG_DEBUG, CTX_data_scene(), CTX_data_view_layer(), Object::data, GS, ID_CHECK_UNDO, LOG, Object::mode, ID::name, OB_MODE_ALL_PAINT, OB_MODE_EDIT, OB_MODE_VERTEX_PAINT, OB_MODE_WEIGHT_PAINT, ptr, and RNA_struct_undo_check().

Referenced by radial_control_modal(), and ui_apply_but_undo().

◆ ED_undo_is_memfile_compatible()

◆ 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 63 of file ed_undo.cc.

References C, CTX_wm_manager(), and wmWindowManager::runtime.

Referenced by wm_event_do_handlers().

◆ ED_undo_is_valid()

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

Name optionally, function used to check for operator redo panel.

Definition at line 381 of file ed_undo.cc.

References BKE_undosys_stack_has_undo(), C, and CTX_wm_manager().

Referenced by WM_operator_check_ui_enabled().

◆ ED_undo_object_editmode_restore_helper()

◆ ED_undo_object_editmode_validate_scene_from_windows()

void ED_undo_object_editmode_validate_scene_from_windows ( wmWindowManager * wm,
const Scene * scene_ref,
Scene ** scene_p,
ViewLayer ** view_layer_p )

This function addresses the problem of restoring undo steps when multiple windows are used. Since undo steps don't track the full context that created them it's possible an edit-mode undo step will attempt to restore edit-mode into a different window, scene or view-layer.

Values scene_p & view_layer_p (typically initialized from the context) are updated from the visible windows using scene_ref as a reference. If the no window can be found, the values are left as-is.

Since users may close windows before undoing, it's expected the window may be unavailable. When this happens the edit-mode objects wont be restored into edit-mode by ED_undo_object_editmode_restore_helper which is acceptable since objects which aren't visible in any window don't need to enter edit-mode.

Definition at line 794 of file ed_undo.cc.

References LISTBASE_FOREACH, and WM_window_get_active_view_layer().

Referenced by armature_undosys_step_decode(), curve_undosys_step_decode(), font_undosys_step_decode(), lattice_undosys_step_decode(), mball_undosys_step_decode(), mesh_undosys_step_decode(), particle_undosys_step_decode(), blender::ed::curves::undo::step_decode(), blender::ed::greasepencil::undo::step_decode(), and blender::ed::pointcloud::undo::step_decode().

◆ ED_undo_object_set_active_or_warn()

◆ ED_undo_operator_repeat()

◆ ED_undo_operator_repeat_cb()

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

Convenience since UI callbacks use this mostly.

Definition at line 708 of file ed_undo.cc.

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 arg_unused )

Definition at line 713 of file ed_undo.cc.

References C, and ED_undo_operator_repeat().

Referenced by uiTemplateOperatorRedoProperties().

◆ ED_undo_pop()

void ED_undo_pop ( bContext * C)

Definition at line 350 of file ed_undo.cc.

References C, ed_undo_step_direction(), 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 98 of file ed_undo.cc.

References BKE_undosys_print(), BKE_undosys_stack_limit_steps_and_memory(), BKE_undosys_step_push(), C, CLG_LEVEL_DEBUG, CLOG_CHECK, CLOG_INFO, CTX_wm_manager(), G, LOG, memory_limit, NC_WM, ND_LIB_OVERRIDE_CHANGED, wmWindowManager::runtime, str, U, UNDO_PUSH_RET_OVERRIDE_CHANGED, WM_file_tag_modified(), and WM_main_add_notifier().

Referenced by blender::ed::space_node::attribute_search_exec_fn(), blender::nodes::attribute_search_exec_fn(), clear_render_border_exec(), colorband_add(), colorband_buttons_layout(), colorband_distribute(), colorband_flip(), colorband_tools_fn(), curve_profile_presets_fn(), curve_profile_tools_fn(), curvemap_tools_func(), delete_fmodifier_cb(), blender::ui::bonecollections::BoneCollectionItem::delete_item(), blender::ui::greasepencil::LayerGroupViewItem::delete_item(), blender::ui::greasepencil::LayerViewItem::delete_item(), blender::ed::outliner::do_outliner_item_editmode_toggle(), blender::ed::outliner::do_outliner_item_mode_toggle_generic(), blender::ed::outliner::do_outliner_item_posemode_toggle(), driver_add_var_cb(), driver_delete_var_cb(), blender::ed::asset_browser::AssetCatalogDropTarget::drop_assets_into_catalog(), drop_color_invoke(), ED_undo_grouped_push(), ed_undo_push_exec(), ED_undo_push_op(), blender::ui::greasepencil::eyedropper_add_material(), file_browse_exec(), fly_modal(), fmodifier_reorder(), gizmo_tweak_finish(), blender::ed::space_node::grid_search_exec_fn(), blender::io::usd::import_endjob(), import_endjob(), blender::nodes::layer_name_search_exec_fn(), blender::ed::space_node::layer_search_exec_fn(), blender::ed::outliner::namebutton_fn(), blender::ed::object::object_transfer_mode_to_base(), blender::ed::object::shapekey::ShapeKeyItem::on_activate(), blender::ui::bonecollections::BoneCollectionItem::on_activate(), blender::ui::greasepencil::LayerGroupViewItem::on_activate(), blender::ui::greasepencil::LayerViewItem::on_activate(), blender::ed::object::shapekey::ShapeKeyDropTarget::on_drop(), blender::ui::bonecollections::BoneCollectionDropTarget::on_drop(), blender::ui::greasepencil::LayerNodeDropTarget::on_drop(), blender::ed::outliner::outliner_action_set_exec(), blender::ed::outliner::outliner_animdata_operation_exec(), blender::ed::outliner::outliner_constraint_operation_exec(), blender::ed::outliner::outliner_data_operation_exec(), blender::ed::outliner::outliner_id_operation_exec(), blender::ed::outliner::outliner_lib_operation_exec(), blender::ed::outliner::outliner_liboverride_operation_exec(), blender::ed::outliner::outliner_modifier_operation_exec(), blender::ed::outliner::outliner_object_operation_exec(), blender::ed::outliner::outliner_scene_operation_exec(), pack_islands_endjob(), blender::ed::sculpt_paint::undo::push_multires_mesh_end(), radial_control_modal(), blender::ed::object::shapekey::ShapeKeyItem::rename(), blender::ui::bonecollections::BoneCollectionItem::rename(), blender::ui::greasepencil::LayerGroupViewItem::rename(), blender::ui::greasepencil::LayerViewItem::rename(), render_border_exec(), template_id_cb(), text_autocomplete_invoke(), text_autocomplete_modal(), ui_apply_but_funcs_after(), blender::ed::space_node::ui_node_link(), view3d_camera_lock_undo_ex(), view3d_collection_drop_copy_external_asset(), and walk_modal().

◆ ED_undo_push_op()

◆ ED_undo_redo()

void ED_undo_redo ( bContext * C)

Definition at line 354 of file ed_undo.cc.

References C, ed_undo_step_direction(), and STEP_REDO.

Referenced by ED_undo_operator_repeat(), and redraw_timer_step().

◆ ED_undo_stack_get()

◆ ED_undosys_stack_memfile_get_if_active()

MemFile * ED_undosys_stack_memfile_get_if_active ( UndoStack * ustack)

◆ ED_undosys_stack_memfile_id_changed_tag()

void ED_undosys_stack_memfile_id_changed_tag ( UndoStack * ustack,
ID * id )

If the last undo step is a memfile one, find the first MemFileChunk matching given ID (using its session UUID), and tag it as "changed in the future".

Since non-memfile undo-steps cannot automatically set this flag in the previous step as done with memfile ones, this has to be called manually by relevant undo code.

Note
Only current known case for this is undoing a switch from Object to Sculpt mode (see #82388).
Calling this ID by ID is not optimal, as it will loop over all MemFile.chunks until it finds the expected one. If this becomes an issue we'll have to add a mapping from session UUID to first MemFileChunk in MemFile itself (currently we only do that in MemFileWriteData when writing a new step).

Definition at line 397 of file memfile_undo.cc.

References BKE_UNDOSYS_TYPE_MEMFILE, MemFile::chunks, LISTBASE_FOREACH, ID::session_uid, UndoStack::step_active, and UndoStep::type.

Referenced by blender::ed::sculpt_paint::undo::geometry_begin_ex(), blender::ed::sculpt_paint::undo::push_begin_ex(), and blender::ed::sculpt_paint::undo::push_enter_sculpt_mode().

◆ ED_undosys_total_memory_calc()

size_t ED_undosys_total_memory_calc ( UndoStack * ustack)

Get the total memory usage of all undo steps in the current undo stack.

This function iterates through all undo steps and calculates their memory consumption. For sculpt undo steps, it uses the specialized sculpt memory calculation function. For other undo step types, it uses the generic data_size field.

Returns
Total memory usage in bytes, or 0 if no undo stack is available.

Definition at line 916 of file ed_undo.cc.

References BKE_UNDOSYS_TYPE_SCULPT, ListBase::first, UndoStep::next, blender::ed::sculpt_paint::undo::step_memory_size_get(), and UndoStack::steps.

Referenced by bpy_app_memory_usage_undo().

◆ ED_undosys_type_free()

void ED_undosys_type_free ( )

Definition at line 61 of file undo_system_types.cc.

References BKE_undosys_type_free_all().

Referenced by WM_exit_ex().

◆ ED_undosys_type_init()