From 0095a07f12854d4df2d8f0f75c0d413d0c63702a Mon Sep 17 00:00:00 2001 From: prculley Date: Fri, 20 Sep 2019 09:16:55 -0500 Subject: [PATCH] Fix Reorder ID tool to avoid scrambling the order IDs are assigned Fixes #10641 --- gramps/plugins/tool/reorderids.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gramps/plugins/tool/reorderids.py b/gramps/plugins/tool/reorderids.py index a61ad28c6..2176537d0 100644 --- a/gramps/plugins/tool/reorderids.py +++ b/gramps/plugins/tool/reorderids.py @@ -247,7 +247,7 @@ class ReorderIds(tool.BatchTool, ManagedWindow, UpdateCallback): self.prim_methods, self.obj_methods = {}, {} for prim_obj, prim_objs in self.xobjects: - iter_handles = "iter_%s_handles" % prim_obj + get_handles = "get_%s_handles" % prim_obj get_number_obj = "get_number_of_%s" % prim_objs prefix_fmt = "%s_prefix" % prim_obj get_from_id = "get_%s_from_gramps_id" % prim_obj @@ -258,7 +258,7 @@ class ReorderIds(tool.BatchTool, ManagedWindow, UpdateCallback): self.prim_methods[prim_obj] = (getattr(self.db, prefix_fmt), getattr(self.db, get_number_obj)(), getattr(self.db, next_from_id)()) - self.obj_methods[prim_obj] = (getattr(self.db, iter_handles), + self.obj_methods[prim_obj] = (getattr(self.db, get_handles), getattr(self.db, commit), getattr(self.db, get_from_id), getattr(self.db, get_from_handle), @@ -578,7 +578,7 @@ class ReorderIds(tool.BatchTool, ManagedWindow, UpdateCallback): dup_ids = [] # list of duplicate identifiers new_ids = {} # list of new identifiers - iter_handles, commit, get_from_id, get_from_handle, next_from_id = \ + get_handles, commit, get_from_id, get_from_handle, next_from_id = \ self.obj_methods[prim_obj] prefix_fmt = self.obj_values[prim_obj].get_fmt() @@ -591,8 +591,12 @@ class ReorderIds(tool.BatchTool, ManagedWindow, UpdateCallback): change = self.obj_values[prim_obj].get_change() index_max = int("9" * self.obj_values[prim_obj].width_fmt) do_same = False + # Process in handle order, which is in order handles were created. + # This makes renumberd IDs more consistant. + handles = get_handles() + handles.sort() - for handle in iter_handles(): + for handle in handles: # Update progress if self.uistate: self.progress.step()