Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
history_snapshot_repository.c File Reference
#include "database/history_snapshot_repository.h"
#include "database/database.h"
#include "database/sql_debug.h"
#include "system/macros.h"
#include <sqlite3.h>
+ Include dependency graph for history_snapshot_repository.c:

Go to the source code of this file.

Functions

static gboolean _run_snap_imgid (const char *query, const int snap_id, const int32_t imgid, const int expected)
 
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.
 

Function Documentation

◆ _run_snap_imgid()

static gboolean _run_snap_imgid ( const char *  query,
const int  snap_id,
const int32_t  imgid,
const int  expected 
)
static

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

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().