Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
history_snapshot_repository.h File Reference

memory.undo_history, memory.undo_masks_history, memory.undo_module_order. More...

#include <glib.h>
#include <stdint.h>
+ Include dependency graph for history_snapshot_repository.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

G_BEGIN_DECLS int dt_history_snapshot_repository_next_id (const int32_t imgid)
 The id the next snapshot of imgid should use: one past the highest taken.
 
gboolean dt_history_snapshot_repository_create (const int snap_id, const int32_t imgid, const gboolean empty_history)
 Copy imgid's history, masks history and module order into the undo tables.
 
gboolean dt_history_snapshot_repository_restore (const int snap_id, const int32_t imgid)
 Copy snapshot snap_id of imgid back over the live history tables.
 
void dt_history_snapshot_repository_clear (const int snap_id, const int32_t imgid)
 Drop snapshot snap_id of imgid from all three undo tables.
 

Detailed Description

memory.undo_history, memory.undo_masks_history, memory.undo_module_order.

The lighttable's undo for history operations does not keep an in-memory record of what changed – it copies the three history tables into three memory. twins before the operation and copies them back to undo it. So every function here is a bulk table-to-table copy, which is also why they are here rather than expressed as reads and writes of dt_dev_history_item_t: the rows never become C structs at all.

common/history_snapshot.c keeps the undo bookkeeping – the snapshot ids on dt_undo_lt_history_t, the history-end handling, the image-cache invalidation.

Definition in file history_snapshot_repository.h.

Function Documentation

◆ dt_history_snapshot_repository_clear()

void dt_history_snapshot_repository_clear ( const int  snap_id,
const int32_t  imgid 
)

Drop snapshot snap_id of imgid from all three undo tables.

Definition at line 140 of file history_snapshot_repository.c.

References _run_snap_imgid(), and L.

Referenced by _clear_undo_snapshot().

◆ dt_history_snapshot_repository_create()

gboolean dt_history_snapshot_repository_create ( const int  snap_id,
const int32_t  imgid,
const gboolean  empty_history 
)

Copy imgid's history, masks history and module order into the undo tables.

Parameters
empty_historyTRUE when the image has no history at all. A placeholder row goes into memory.undo_history instead of the three copies, so that the next dt_history_snapshot_repository_next_id() still counts this snapshot.
Returns
TRUE when every statement succeeded. The whole thing is one transaction and rolls back otherwise.

Definition at line 56 of file history_snapshot_repository.c.

References _run_snap_imgid(), dt_database_release_transaction, dt_database_rollback_transaction(), dt_database_start_transaction, L, and TRUE.

Referenced by dt_history_snapshot_undo_create().

◆ dt_history_snapshot_repository_next_id()

G_BEGIN_DECLS int dt_history_snapshot_repository_next_id ( const int32_t  imgid)

The id the next snapshot of imgid should use: one past the highest taken.

Definition at line 41 of file history_snapshot_repository.c.

References dt_database_get_sqlite3_global(), DT_DEBUG_SQLITE3_BIND_INT, DT_DEBUG_SQLITE3_PREPARE_V2, and L.

Referenced by dt_history_snapshot_undo_create().

◆ dt_history_snapshot_repository_restore()

gboolean dt_history_snapshot_repository_restore ( const int  snap_id,
const int32_t  imgid 
)

Copy snapshot snap_id of imgid back over the live history tables.

Warning
The caller must have cleared the live history first, and must be inside its own transaction: restoring is only half of an operation whose other half (dt_history_delete_on_image_ext(), dt_history_repository_set_end()) is domain code this module must not call. common/history_snapshot.c opens the transaction around both.

Definition at line 111 of file history_snapshot_repository.c.

References _run_snap_imgid(), and L.

Referenced by _history_snapshot_undo_restore().