From 4e6a06bfacdef5e803dbacdaef2961bd1da9ffac Mon Sep 17 00:00:00 2001 From: kulath Date: Thu, 18 Jun 2015 22:52:53 +0100 Subject: [PATCH] 0008537: Gedcom import crashes. Fix problem when matching places with the same name which are enclosed by different places. --- gramps/plugins/lib/libgedcom.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/gramps/plugins/lib/libgedcom.py b/gramps/plugins/lib/libgedcom.py index f48d6a7c6..2428d6ab7 100644 --- a/gramps/plugins/lib/libgedcom.py +++ b/gramps/plugins/lib/libgedcom.py @@ -2997,7 +2997,7 @@ class GedcomParser(UpdateCallback): return True return False - def __find_place(self, title, location): + def __find_place(self, title, location, placeref_list): """ Finds an existing place based on the title and primary location. @@ -3011,11 +3011,13 @@ class GedcomParser(UpdateCallback): place = self.dbase.get_place_from_handle(place_handle) if place.get_title() == title: if self.__loc_is_empty(location) and \ - self.__loc_is_empty(self.__get_first_loc(place)): + self.__loc_is_empty(self.__get_first_loc(place)) and \ + place.get_placeref_list() == placeref_list: return place elif (not self.__loc_is_empty(location) and \ not self.__loc_is_empty(self.__get_first_loc(place)) and - self.__get_first_loc(place).is_equivalent(location) == IDENTICAL): + self.__get_first_loc(place).is_equivalent(location) == IDENTICAL) and \ + place.get_placeref_list() == placeref_list: return place return None @@ -3033,7 +3035,8 @@ class GedcomParser(UpdateCallback): if sub_state.place: # see whether this place already exists place = self.__find_place(sub_state.place.get_title(), - self.__get_first_loc(sub_state.place)) + self.__get_first_loc(sub_state.place), + sub_state.place.get_placeref_list()) if place is None: place = sub_state.place self.dbase.add_place(place, self.trans) @@ -4617,7 +4620,7 @@ class GedcomParser(UpdateCallback): """ try: title = line.data - place = self.__find_place(title, None) + place = self.__find_place(title, None, None) if place is None: place = Place() place.set_title(title) @@ -5604,7 +5607,8 @@ class GedcomParser(UpdateCallback): if self.addr_is_detail and state.place: # Commit the enclosing place - place = self.__find_place(state.place.get_title(), None) + place = self.__find_place(state.place.get_title(), None, + state.place.get_placeref_list()) if place is None: place = state.place self.dbase.add_place(place, self.trans)