From a99b56e123bdb394beffd90967cb6805f44108c2 Mon Sep 17 00:00:00 2001 From: SNoiraud Date: Mon, 25 Jan 2016 11:10:13 +0100 Subject: [PATCH] 7619 : Notes used in the "To Do" gramplet are found by the Remove Unused Objects tool --- gramps/plugins/tool/removeunused.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/gramps/plugins/tool/removeunused.py b/gramps/plugins/tool/removeunused.py index 6b74aa9f4..dfd2d2345 100644 --- a/gramps/plugins/tool/removeunused.py +++ b/gramps/plugins/tool/removeunused.py @@ -61,6 +61,7 @@ from gramps.gen.display.place import displayer as _pd from gramps.gen.updatecallback import UpdateCallback from gramps.gui.plug import tool from gramps.gui.glade import Glade +from gramps.gen.filters import GenericFilterFactory, rules #------------------------------------------------------------------------- # @@ -266,6 +267,15 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback): ('notes', db.get_note_cursor, db.get_number_of_notes), ) + # bug 7619 : don't select notes from to do list. + # notes associated to the todo list doesn't have references. + # get the todo list (from get_note_list method of the todo gramplet ) + all_notes = self.dbstate.db.get_note_handles() + FilterClass = GenericFilterFactory('Note') + filter = FilterClass() + filter.add_rule(rules.note.HasType(["To Do"])) + todo_list = filter.apply(self.dbstate.db, all_notes) + for (the_type, cursor_func, total_func) in tables: if not self.options.handler.options_dict[the_type]: # This table was not requested. Skip it. @@ -276,8 +286,9 @@ class RemoveUnused(tool.Tool, ManagedWindow, UpdateCallback): fbh = db.find_backlink_handles for handle, data in cursor: if not any(h for h in fbh(handle)): - self.add_results((the_type, handle.decode('utf-8'), - data)) + if handle not in todo_list: + self.add_results((the_type, handle.decode('utf-8'), + data)) self.update() self.reset()