From 607d4889d60284af82d8b096697ead0adcd0bbba Mon Sep 17 00:00:00 2001 From: Tom Samstag Date: Tue, 29 Mar 2016 00:11:56 -0700 Subject: [PATCH] fix the name map of tags in DictionaryDb DictionaryDb had a bug where the same tag could end up in the name mapping multiple times. This was most easily seen when loading a gramps xml into a DictionaryDb, where an extra entry with the tag name of '' would be created and would ultimately be referencing the last-created Tag (also referenced by its proper tag name). This change makes sure that when editing a tag, any existing references in the name mapping are deleted before adding. --- gramps/plugins/database/dictionarydb.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gramps/plugins/database/dictionarydb.py b/gramps/plugins/database/dictionarydb.py index 3641b77a5..a1c0afdb8 100644 --- a/gramps/plugins/database/dictionarydb.py +++ b/gramps/plugins/database/dictionarydb.py @@ -520,6 +520,11 @@ class DictionaryDb(DbGeneric): emit = None if tag.handle in self.tag_map: emit = "tag-update" + existing_names = [existing_name for existing_name, existing_tag in + self._tag_name_dict.items() + if existing_tag.handle == tag.handle] + for existing_name in existing_names: + del self._tag_name_dict[existing_name] self._tag_dict[tag.handle] = tag self._tag_name_dict[tag.name] = tag else: