Fix Reorder ID tool to avoid scrambling the order IDs are assigned
Fixes #10641
This commit is contained in:
parent
bb5b03dd78
commit
0095a07f12
@ -247,7 +247,7 @@ class ReorderIds(tool.BatchTool, ManagedWindow, UpdateCallback):
|
|||||||
|
|
||||||
self.prim_methods, self.obj_methods = {}, {}
|
self.prim_methods, self.obj_methods = {}, {}
|
||||||
for prim_obj, prim_objs in self.xobjects:
|
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
|
get_number_obj = "get_number_of_%s" % prim_objs
|
||||||
prefix_fmt = "%s_prefix" % prim_obj
|
prefix_fmt = "%s_prefix" % prim_obj
|
||||||
get_from_id = "get_%s_from_gramps_id" % 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),
|
self.prim_methods[prim_obj] = (getattr(self.db, prefix_fmt),
|
||||||
getattr(self.db, get_number_obj)(),
|
getattr(self.db, get_number_obj)(),
|
||||||
getattr(self.db, next_from_id)())
|
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, commit),
|
||||||
getattr(self.db, get_from_id),
|
getattr(self.db, get_from_id),
|
||||||
getattr(self.db, get_from_handle),
|
getattr(self.db, get_from_handle),
|
||||||
@ -578,7 +578,7 @@ class ReorderIds(tool.BatchTool, ManagedWindow, UpdateCallback):
|
|||||||
dup_ids = [] # list of duplicate identifiers
|
dup_ids = [] # list of duplicate identifiers
|
||||||
new_ids = {} # list of new 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]
|
self.obj_methods[prim_obj]
|
||||||
|
|
||||||
prefix_fmt = self.obj_values[prim_obj].get_fmt()
|
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()
|
change = self.obj_values[prim_obj].get_change()
|
||||||
index_max = int("9" * self.obj_values[prim_obj].width_fmt)
|
index_max = int("9" * self.obj_values[prim_obj].width_fmt)
|
||||||
do_same = False
|
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
|
# Update progress
|
||||||
if self.uistate:
|
if self.uistate:
|
||||||
self.progress.step()
|
self.progress.step()
|
||||||
|
Loading…
Reference in New Issue
Block a user