From 26d491b23023454ef6998959699749c07c10d43b Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 19 Jul 2006 04:29:04 +0000 Subject: [PATCH] 2006-07-18 Alex Roitman * src/GrampsDb/_GrampsBSDDB.py (GrampsBSDDB._delete_primary_from_reference_map): defer deleting until the cursor is closed. svn: r7040 --- ChangeLog | 5 +++++ src/GrampsDb/_GrampsBSDDB.py | 11 +++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1a9759623..afd25c23f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-07-18 Alex Roitman + * src/GrampsDb/_GrampsBSDDB.py + (GrampsBSDDB._delete_primary_from_reference_map): defer deleting + until the cursor is closed. + 2006-07-18 Brian Matherly * src/plugins/GraphViz.py: Make it work for Windows diff --git a/src/GrampsDb/_GrampsBSDDB.py b/src/GrampsDb/_GrampsBSDDB.py index 360705ce8..ba99b9e49 100644 --- a/src/GrampsDb/_GrampsBSDDB.py +++ b/src/GrampsDb/_GrampsBSDDB.py @@ -619,6 +619,7 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback): except: ret = None + remove_list = set() while (ret is not None): (key,data) = ret @@ -630,12 +631,18 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback): # combine with the primary_handle to get the main key. main_key = (handle, pickle.loads(data)[1][1]) - - self._remove_reference(main_key,transaction,txn) + # The trick is not to remove while inside the cursor, + # but collect them all and remove after the cursor is closed + remove_list.add(main_key) + ret = primary_cur.next_dup() primary_cur.close() + + # Now that the cursor is closed, we can remove things + for main_key in remove_list: + self._remove_reference(main_key,transaction,txn) def _update_reference_map(self, obj, transaction, txn=None): """