diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-08 19:43:46 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-05-08 19:43:46 +0200 |
commit | 48ec4cb1fb00b303460302c0eaa17c7ffaabca05 (patch) | |
tree | 8392f75d688e1860bf946d08e71b4b6141ea1795 | |
parent | 7cf18de071f28f2968624371a489d7dc9d437f87 (diff) |
Clear wallpaper's tags before removal.
-rw-r--r-- | db.c | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -278,10 +278,33 @@ sqlite_uint64 db_get_wallpaper(const char *path) { return 0; } +static void db_clear_wall_tags(sqlite_uint64 wallid) { + sqlite3_stmt *stmt; + int rc; + + rc = sqlite3_prepare_v2(db, "DELETE FROM walltags WHERE wallid = ?", -1, &stmt, NULL); + + if(rc != SQLITE_OK) { + return; + } + + rc = sqlite3_bind_int64(stmt, 1, wallid); + if(rc != SQLITE_OK) { + sqlite3_finalize(stmt); + return; + } + + sqlite3_step(stmt); + + sqlite3_finalize(stmt); +} + int db_remove_wallpaper(sqlite_uint64 id) { sqlite3_stmt *stmt; int rc; + db_clear_wall_tags(id); + rc = sqlite3_prepare_v2(db, "DELETE FROM wallpaper WHERE id = ?", -1, &stmt, NULL); if(rc != SQLITE_OK) { return 0; |