Blender V4.3
memfile_undo.cc File Reference
#include "BLI_sys_types.h"
#include "BLI_utildefines.h"
#include "BLI_ghash.h"
#include "BLI_listbase.h"
#include "DNA_ID.h"
#include "DNA_collection_types.h"
#include "DNA_node_types.h"
#include "DNA_object_enums.h"
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "BKE_blender_undo.hh"
#include "BKE_context.hh"
#include "BKE_lib_query.hh"
#include "BKE_main.hh"
#include "BKE_node.hh"
#include "BKE_preview_image.hh"
#include "BKE_scene.hh"
#include "BKE_undo_system.hh"
#include "../depsgraph/DEG_depsgraph.hh"
#include "WM_api.hh"
#include "WM_types.hh"
#include "ED_render.hh"
#include "ED_undo.hh"
#include "ED_util.hh"
#include "../blenloader/BLO_undofile.hh"
#include "undo_intern.hh"
#include <cstdio>

Go to the source code of this file.

Classes

struct  MemFileUndoStep
 

Functions

Implements ED Undo System
static bool memfile_undosys_poll (bContext *C)
 
static bool memfile_undosys_step_encode (bContext *, Main *bmain, UndoStep *us_p)
 
static int memfile_undosys_step_id_reused_cb (LibraryIDLinkCallbackData *cb_data)
 
static void memfile_undosys_unfinished_id_previews_restart (ID *id)
 
static void memfile_undosys_step_decode (bContext *C, Main *bmain, UndoStep *us_p, const eUndoStepDir undo_direction, bool)
 
static void memfile_undosys_step_free (UndoStep *us_p)
 
void ED_memfile_undosys_type (UndoType *ut)
 
Utilities
static MemFileed_undosys_step_get_memfile (UndoStep *us_p)
 
MemFileED_undosys_stack_memfile_get_if_active (UndoStack *ustack)
 
void ED_undosys_stack_memfile_id_changed_tag (UndoStack *ustack, ID *id)
 

Detailed Description

Wrapper between 'ED_undo.hh' and 'BKE_undo_system.hh' API's.

Definition in file memfile_undo.cc.

Function Documentation

◆ ED_memfile_undosys_type()

◆ 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 368 of file memfile_undo.cc.

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

Referenced by blender::ed::sculpt_paint::undo::push_begin_ex().

◆ ed_undosys_step_get_memfile()

static MemFile * ed_undosys_step_get_memfile ( UndoStep * us_p)
static

Ideally we wouldn't need to export global undo internals, there are some cases where it's needed though.

Definition at line 351 of file memfile_undo.cc.

References MemFileUndoStep::data, and MemFileUndoData::memfile.

Referenced by ED_undosys_stack_memfile_get_if_active().

◆ memfile_undosys_poll()

static bool memfile_undosys_poll ( bContext * C)
static

◆ memfile_undosys_step_decode()

◆ memfile_undosys_step_encode()

◆ memfile_undosys_step_free()

static void memfile_undosys_step_free ( UndoStep * us_p)
static

◆ memfile_undosys_step_id_reused_cb()

◆ memfile_undosys_unfinished_id_previews_restart()

static void memfile_undosys_unfinished_id_previews_restart ( ID * id)
static

ID previews may be generated in a parallel job. So whatever operation generates the preview likely does the undo push before the preview is actually done and stored in the ID. Hence they get some extra treatment here: When undoing back to the moment the preview generation was triggered, this function schedules the preview for regeneration.

Definition at line 138 of file memfile_undo.cc.

References BKE_previewimg_id_get(), BKE_previewimg_is_finished(), ED_preview_restart_queue_add(), PreviewImage::flag, NUM_ICON_SIZES, and PRV_USER_EDITED.

Referenced by memfile_undosys_step_decode().