diff --git a/ChangeLog b/ChangeLog index 7bd497838..a0640df6d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-06-06 Alex Roitman + * src/GrampsDb/_DbUtils.py (set_birth_death_index): Only set birth + and death references for events with primary role. + 2006-06-05 Don Allingham * src/GrampsDb/_ReadGedcom.py: more improvements diff --git a/src/GrampsDb/_DbUtils.py b/src/GrampsDb/_DbUtils.py index 87179ba5d..2f17854ab 100644 --- a/src/GrampsDb/_DbUtils.py +++ b/src/GrampsDb/_DbUtils.py @@ -274,16 +274,20 @@ def update_secondary_inmem(sec_table,handle,data): sec_table[str(data[1])] = str(handle) def set_birth_death_index(db, person): - birth = -1 - death = -1 - index = 0 - for ref in person.get_event_ref_list(): + birth_ref_index = -1 + death_ref_index = -1 + event_ref_list = person.get_event_ref_list() + for index in range(len(event_ref_list)): + ref = event_ref_list[index] event = db.get_event_from_handle(ref.ref) - if int(event.get_type()) == RelLib.EventType.BIRTH and birth == -1: - birth = index - elif int(event.get_type()) == RelLib.EventType.DEATH and death == -1: - death = index - index += 1 - person.birth_ref_index = birth - person.death_ref_index = death - + if (int(event.get_type()) == RelLib.EventType.BIRTH) \ + and (int(ref.get_role()) == RelLib.EventRoleType.PRIMARY) \ + and (birth_ref_index == -1): + birth_ref_index = index + elif (int(event.get_type()) == RelLib.EventType.DEATH) \ + and (int(ref.get_role()) == RelLib.EventRoleType.PRIMARY) \ + and (death_ref_index == -1): + death_ref_index = index + + person.birth_ref_index = birth_ref_index + person.death_ref_index = death_ref_index