42 gboolean all_ok =
TRUE;
51 "SELECT MAX(id) FROM memory.undo_history WHERE imgid=?1", -1, &stmt, NULL);
54 if (sqlite3_step(stmt) == SQLITE_ROW)
55 *snap_id = sqlite3_column_int(stmt, 0) + 1;
56 sqlite3_finalize(stmt);
65 "INSERT INTO memory.undo_history"
66 " VALUES (?1, ?2, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)"
71 all_ok = all_ok && (sqlite3_step(stmt) == SQLITE_DONE);
80 "INSERT INTO memory.undo_history"
81 " SELECT ?1, imgid, num, module, operation, op_params, enabled, "
82 " blendop_params, blendop_version, multi_priority, multi_name "
84 " WHERE imgid=?2", -1, &stmt, NULL);
88 all_ok = all_ok && (sqlite3_step(stmt) == SQLITE_DONE);
89 sqlite3_finalize(stmt);
95 "INSERT INTO memory.undo_masks_history"
96 " SELECT ?1, imgid, num, formid, form, name, version,"
97 " points, points_count, source"
98 " FROM main.masks_history"
99 " WHERE imgid=?2", -1, &stmt, NULL);
103 all_ok = all_ok && (sqlite3_step(stmt) == SQLITE_DONE);
104 sqlite3_finalize(stmt);
110 "INSERT INTO memory.undo_module_order"
111 " SELECT ?1, imgid, version, iop_list"
112 " FROM main.module_order"
113 " WHERE imgid=?2", -1, &stmt, NULL);
117 all_ok = all_ok && (sqlite3_step(stmt) == SQLITE_DONE);
121 sqlite3_finalize(stmt);
128 fprintf(stderr,
"[dt_history_snapshot_undo_create] fails to create a snapshot for %d\n", imgid);
136 gboolean all_ok =
TRUE;
153 "INSERT INTO main.history"
154 " SELECT imgid, num, module, operation, op_params, enabled, "
155 " blendop_params, blendop_version, multi_priority, multi_name "
156 " FROM memory.undo_history"
157 " WHERE imgid=?2 AND id=?1", -1, &stmt, NULL);
161 all_ok &= (sqlite3_step(stmt) == SQLITE_DONE);
162 sqlite3_finalize(stmt);
168 "INSERT INTO main.masks_history"
169 " SELECT imgid, num, formid, form, name, version, "
170 " points, points_count, source"
171 " FROM memory.undo_masks_history"
172 " WHERE imgid=?2 AND id=?1",
177 all_ok &= (sqlite3_step(stmt) == SQLITE_DONE);
178 sqlite3_finalize(stmt);
184 "INSERT INTO main.module_order"
185 " SELECT imgid, version, iop_list"
186 " FROM memory.undo_module_order"
187 " WHERE imgid=?2 AND id=?1", -1, &stmt, NULL);
191 all_ok &= (sqlite3_step(stmt) == SQLITE_DONE);
192 sqlite3_finalize(stmt);
204 fprintf(stderr,
"[_history_snapshot_undo_restore] fails to restore a snapshot for %d\n", imgid);
221 "DELETE FROM memory.undo_history WHERE id=?1 AND imgid=?2", -1, &stmt, NULL);
225 sqlite3_finalize(stmt);
228 "DELETE FROM memory.undo_masks_history WHERE id=?1 AND imgid=?2", -1, &stmt, NULL);
232 sqlite3_finalize(stmt);
235 "DELETE FROM memory.undo_module_order WHERE id=?1 AND imgid=?2", -1, &stmt, NULL);
239 sqlite3_finalize(stmt);
270 *imgs = g_list_append(*imgs, GINT_TO_POINTER(hist->
imgid));
gboolean dt_history_set_end(const int32_t imgid, const int32_t history_end)
int32_t dt_history_get_end(const int32_t imgid)
void dt_history_delete_on_image_ext(int32_t imgid, gboolean undo)
sqlite3 * dt_database_get(const dt_database_t *db)
void dt_database_rollback_transaction(const struct dt_database_t *db)
#define dt_database_start_transaction(db)
#define dt_database_release_transaction(db)
#define DT_DEBUG_SQLITE3_PREPARE_V2(a, b, c, d, e)
#define DT_DEBUG_SQLITE3_BIND_INT(a, b, c)
void dt_history_snapshot_undo_create(const int32_t imgid, int *snap_id, int *history_end)
void dt_history_snapshot_undo_lt_history_data_free(gpointer data)
static void _clear_undo_snapshot(const int32_t imgid, const int snap_id)
dt_undo_lt_history_t * dt_history_snapshot_item_init(void)
void dt_history_snapshot_undo_pop(gpointer user_data, dt_undo_type_t type, dt_undo_data_t data, dt_undo_action_t action, GList **imgs)
static void _history_snapshot_undo_restore(const int32_t imgid, const int snap_id, const int history_end)
dt_image_t * dt_image_cache_get(dt_image_cache_t *cache, const int32_t imgid, char mode)
void dt_image_cache_write_release(dt_image_cache_t *cache, dt_image_t *img, dt_image_cache_write_mode_t mode)
#define DT_DEBUG_CONTROL_SIGNAL_RAISE(ctlsig, signal,...)
@ DT_SIGNAL_TAG_CHANGED
This signal is raised when a tag is added/deleted/changed
const struct dt_database_t * db
struct dt_control_signal_t * signals
struct dt_image_cache_t * image_cache