From 9501b708f82a13e0fda2fac93feae74bdc1cf502 Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Wed, 1 Oct 2008 15:52:17 +0000 Subject: [PATCH] Remove orphaned checklist items when nodes are removed git-svn-id: https://vcs.maemo.org/svn/maemopadplus/trunk/unified@77 5e5308f7-2816-0410-9b18-d3ce14e03fc0 --- src/ui/callbacks.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ui/callbacks.c b/src/ui/callbacks.c index 04394ce..e568173 100644 --- a/src/ui/callbacks.c +++ b/src/ui/callbacks.c @@ -1913,6 +1913,12 @@ void callback_delete_node_real(GtkAction * action, gpointer data) snprintf(tq, sizeof(tq), "DELETE FROM %s WHERE nodeid=%d;", datatable_tmpname, sql3id); if (sqlite3_exec(mainview->db, tq, NULL, NULL, NULL) != 0) fprintf(stderr, "ERROR deleting node!\n"); + + /* Delete all checklist items that do not have + * a node anymore (= orphaned checklist items) */ + snprintf(tq, sizeof(tq), "DELETE FROM %s WHERE nodeid NOT IN (SELECT nodeid FROM %s);", checklisttable_tmpname, datatable_tmpname); + if (sqlite3_exec(mainview->db, tq, NULL, NULL, NULL) != 0) + fprintf(stderr, "ERROR deleting orphaned checklist items!\n"); } } gtk_tree_store_remove(GTK_TREE_STORE(model), &iter); -- 2.11.4.GIT