Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/undo/memfile_undo.c
| Show All 18 Lines | |||||
| * | * | ||||
| * Wrapper between 'ED_undo.h' and 'BKE_undo_system.h' API's. | * Wrapper between 'ED_undo.h' and 'BKE_undo_system.h' API's. | ||||
| */ | */ | ||||
| #include "BLI_sys_types.h" | #include "BLI_sys_types.h" | ||||
| #include "BLI_utildefines.h" | #include "BLI_utildefines.h" | ||||
| #include "BLI_ghash.h" | #include "BLI_ghash.h" | ||||
| #include "BLI_listbase.h" | |||||
| #include "DNA_ID.h" | |||||
| #include "DNA_node_types.h" | #include "DNA_node_types.h" | ||||
| #include "DNA_object_enums.h" | #include "DNA_object_enums.h" | ||||
| #include "DNA_object_types.h" | #include "DNA_object_types.h" | ||||
| #include "DNA_scene_types.h" | #include "DNA_scene_types.h" | ||||
| #include "BKE_blender_undo.h" | #include "BKE_blender_undo.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_lib_id.h" | #include "BKE_lib_id.h" | ||||
| Show All 11 Lines | |||||
| #include "ED_object.h" | #include "ED_object.h" | ||||
| #include "ED_undo.h" | #include "ED_undo.h" | ||||
| #include "ED_util.h" | #include "ED_util.h" | ||||
| #include "../blenloader/BLO_undofile.h" | #include "../blenloader/BLO_undofile.h" | ||||
| #include "undo_intern.h" | #include "undo_intern.h" | ||||
| #include <stdio.h> | |||||
| /* -------------------------------------------------------------------- */ | /* -------------------------------------------------------------------- */ | ||||
| /** \name Implements ED Undo System | /** \name Implements ED Undo System | ||||
| * \{ */ | * \{ */ | ||||
| typedef struct MemFileUndoStep { | typedef struct MemFileUndoStep { | ||||
| UndoStep step; | UndoStep step; | ||||
| MemFileUndoData *data; | MemFileUndoData *data; | ||||
| } MemFileUndoStep; | } MemFileUndoStep; | ||||
| ▲ Show 20 Lines • Show All 239 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| UndoStep *us = BKE_undosys_stack_active_with_type(ustack, BKE_UNDOSYS_TYPE_MEMFILE); | UndoStep *us = BKE_undosys_stack_active_with_type(ustack, BKE_UNDOSYS_TYPE_MEMFILE); | ||||
| if (us) { | if (us) { | ||||
| return ed_undosys_step_get_memfile(us); | return ed_undosys_step_get_memfile(us); | ||||
| } | } | ||||
| return NULL; | return NULL; | ||||
| } | } | ||||
| /** | |||||
brecht: This needs a comment explaining what the function does and why it needs to be used. | |||||
| * If the last undo step is a memfile one, find the first memchunk matching given ID (using its | |||||
| * seesion uuid), and tag it as 'changed in the future'. | |||||
| * | |||||
| * Since non-memfile undos 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 Pbject to Sculpt mode (see | |||||
| * T82388). | |||||
| * | |||||
| * \note Calling this ID by ID is not optimal, as it will loop over all memchunks until it find | |||||
| * expected one. If this becomes an issue we'll have to add a mapping from session uuid to first | |||||
| * memchunk in #MemFile itself (currently we only do that in #MemFileWriteData when writing a new | |||||
Not Done Inline ActionsRemove debug print. brecht: Remove debug print. | |||||
| * step). | |||||
| */ | |||||
| void ED_undosys_stack_memfile_id_changed_tag(UndoStack *ustack, ID *id) | |||||
| { | |||||
| UndoStep *us = ustack->step_active; | |||||
| if (id == NULL || us == NULL || us->type != BKE_UNDOSYS_TYPE_MEMFILE) { | |||||
| return; | |||||
| } | |||||
| MemFile *memfile = &((MemFileUndoStep *)us)->data->memfile; | |||||
| LISTBASE_FOREACH (MemFileChunk *, mem_chunk, &memfile->chunks) { | |||||
| if (mem_chunk->id_session_uuid == id->session_uuid) { | |||||
| mem_chunk->is_identical_future = false; | |||||
| break; | |||||
| } | |||||
| } | |||||
| } | |||||
| /** \} */ | /** \} */ | ||||
This needs a comment explaining what the function does and why it needs to be used.