Blender  V3.3
Classes
memfile_undo.c 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.h"
#include "BKE_context.h"
#include "BKE_icons.h"
#include "BKE_lib_id.h"
#include "BKE_lib_query.h"
#include "BKE_main.h"
#include "BKE_node.h"
#include "BKE_scene.h"
#include "BKE_undo_system.h"
#include "../depsgraph/DEG_depsgraph.h"
#include "WM_api.h"
#include "WM_types.h"
#include "ED_object.h"
#include "ED_render.h"
#include "ED_undo.h"
#include "ED_util.h"
#include "../blenloader/BLO_undofile.h"
#include "undo_intern.h"
#include <stdio.h>

Go to the source code of this file.

Classes

struct  MemFileUndoStep
 

Functions

Utilities
static struct MemFileed_undosys_step_get_memfile (UndoStep *us_p)
 
struct MemFileED_undosys_stack_memfile_get_active (UndoStack *ustack)
 
void ED_undosys_stack_memfile_id_changed_tag (UndoStack *ustack, ID *id)
 

Implements ED Undo System

typedef struct MemFileUndoStep MemFileUndoStep
 
static bool memfile_undosys_poll (bContext *C)
 
static bool memfile_undosys_step_encode (struct bContext *UNUSED(C), struct 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 (struct bContext *C, struct Main *bmain, UndoStep *us_p, const eUndoStepDir undo_direction, bool UNUSED(is_final))
 
static void memfile_undosys_step_free (UndoStep *us_p)
 
void ED_memfile_undosys_type (UndoType *ut)
 

Detailed Description

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

Definition in file memfile_undo.c.

Typedef Documentation

◆ MemFileUndoStep

Function Documentation

◆ ED_memfile_undosys_type()

void ED_memfile_undosys_type ( struct UndoType ut)

◆ ED_undosys_stack_memfile_get_active()

struct MemFile* ED_undosys_stack_memfile_get_active ( UndoStack ustack)

◆ ED_undosys_stack_memfile_id_changed_tag()

void ED_undosys_stack_memfile_id_changed_tag ( struct UndoStack ustack,
struct 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 T82388).
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 352 of file memfile_undo.c.

References BKE_UNDOSYS_TYPE_MEMFILE, MemFile::chunks, id, LISTBASE_FOREACH, NULL, ID::session_uuid, UndoStack::step_active, and UndoStep::type.

Referenced by SCULPT_undo_push_begin().

◆ ed_undosys_step_get_memfile()

static struct 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 337 of file memfile_undo.c.

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

Referenced by ED_undosys_stack_memfile_get_active().

◆ memfile_undosys_poll()

static bool memfile_undosys_poll ( bContext C)
static

◆ memfile_undosys_step_decode()

static void memfile_undosys_step_decode ( struct bContext C,
struct Main bmain,
UndoStep us_p,
const eUndoStepDir  undo_direction,
bool   UNUSEDis_final 
)
static

◆ memfile_undosys_step_encode()

static bool memfile_undosys_step_encode ( struct bContext UNUSEDC,
struct Main bmain,
UndoStep us_p 
)
static

◆ memfile_undosys_step_free()

static void memfile_undosys_step_free ( UndoStep us_p)
static

◆ memfile_undosys_step_id_reused_cb()

static int memfile_undosys_step_id_reused_cb ( LibraryIDLinkCallbackData cb_data)
static

◆ 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 140 of file memfile_undo.c.

References BKE_previewimg_id_get(), BKE_previewimg_is_finished(), ED_preview_restart_queue_add(), NUM_ICON_SIZES, usdtokens::preview(), and PRV_USER_EDITED.

Referenced by memfile_undosys_step_decode().