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.
This commit is contained in:
Tom Samstag 2016-03-29 00:11:56 -07:00
parent 28b1db78e0
commit 607d4889d6

View File

@ -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: