From 4cf930d039d5c48176cc8806f521bc3a71276f21 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 16 Jun 2006 03:32:51 +0000 Subject: [PATCH] * src/GrampsDb/_GrampsDbBase.py: prevent null event types and attribute types from being added * src/Editors/_EditAttribute.py: prevent null attribute types * src/Editors/_EditEvent.py: prevent null attribute types * src/AutoComp.py: filter out empty strings * src/ImgManip.py: check for file before attempting thumbnailer svn: r6898 --- ChangeLog | 6 ++++++ src/AutoComp.py | 7 +++++-- src/Editors/_EditAttribute.py | 8 ++++++++ src/Editors/_EditEvent.py | 7 +++++++ src/GrampsDb/_GrampsDbBase.py | 16 ++++++++-------- src/ImgManip.py | 2 +- 6 files changed, 35 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index be566432f..737858f4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ 2006-06-15 Don Allingham + * src/GrampsDb/_GrampsDbBase.py: prevent null event types and + attribute types from being added + * src/Editors/_EditAttribute.py: prevent null attribute types + * src/Editors/_EditEvent.py: prevent null attribute types + * src/AutoComp.py: filter out empty strings + * src/ImgManip.py: check for file before attempting thumbnailer * src/ScratchPad.py: enable Text dnd 2006-06-15 Alex Roitman diff --git a/src/AutoComp.py b/src/AutoComp.py index ce7dc84e1..cbd7f5d65 100644 --- a/src/AutoComp.py +++ b/src/AutoComp.py @@ -139,6 +139,7 @@ class StandardCustomSelector: self.active_key = active_key self.active_index = 0 self.additional = additional + # make model self.store = gtk.ListStore(int,str) @@ -176,9 +177,11 @@ class StandardCustomSelector: if self.additional: for event_type in self.additional: if type(event_type) == str or type(event_type) == unicode : - self.store.append(row=[self.custom_key, event_type]) + if event_type: + self.store.append(row=[self.custom_key, event_type]) elif type(event_type) == tuple: - self.store.append(row=[event_type[0], event_type[1]]) + if event_type[1]: + self.store.append(row=[event_type[0], event_type[1]]) else: self.store.append(row=[int(event_type), str(event_type)]) if key == self.active_key: diff --git a/src/Editors/_EditAttribute.py b/src/Editors/_EditAttribute.py index 34e1085fc..71ec88b6f 100644 --- a/src/Editors/_EditAttribute.py +++ b/src/Editors/_EditAttribute.py @@ -135,6 +135,14 @@ class EditAttribute(EditSecondary): Called when the OK button is pressed. Gets data from the form and updates the Attribute data structure. """ + t = self.obj.get_type() + + if t.is_custom() and str(t) == '': + from QuestionDialog import ErrorDialog + ErrorDialog( + _("Cannot save attribute"), + _("The attribute type cannot be empty")) + return if self.callback: self.callback(self.obj) self.close() diff --git a/src/Editors/_EditEvent.py b/src/Editors/_EditEvent.py index d46f20ce1..398bfd1c3 100644 --- a/src/Editors/_EditEvent.py +++ b/src/Editors/_EditEvent.py @@ -204,6 +204,13 @@ class EditEvent(EditPrimary): "enter data or cancel the edit.")) return + t = self.obj.get_type() + if t.is_custom() and str(t) == '': + ErrorDialog( + _("Cannot save event"), + _("The event type cannot be empty")) + return + if self.obj.handle == None: trans = self.db.transaction_begin() self.db.add_event(self.obj,trans) diff --git a/src/GrampsDb/_GrampsDbBase.py b/src/GrampsDb/_GrampsDbBase.py index 8763ba621..db6772104 100644 --- a/src/GrampsDb/_GrampsDbBase.py +++ b/src/GrampsDb/_GrampsDbBase.py @@ -448,7 +448,7 @@ class GrampsDbBase(GrampsDBCallback): self.individual_attributes.update( [str(attr.type) for attr in person.attribute_list - if attr.type.is_custom()]) + if attr.type.is_custom() and str(attr.type)]) if person.marker.is_custom(): self.marker_names.add(str(person.marker)) @@ -468,7 +468,7 @@ class GrampsDbBase(GrampsDBCallback): attr_list = [] for mref in person.media_list: attr_list += [str(attr.type) for attr in mref.attribute_list - if attr.type.is_custom()] + if attr.type.is_custom() and str(attr.type)] self.media_attributes.update(attr_list) def commit_media_object(self, obj, transaction, change_time=None): @@ -482,7 +482,7 @@ class GrampsDbBase(GrampsDBCallback): transaction, change_time) self.media_attributes.update( [str(attr.type) for attr in obj.attribute_list - if attr.type.is_custom()]) + if attr.type.is_custom() and str(attr.type)]) def commit_source(self, source, transaction, change_time=None): """ @@ -501,7 +501,7 @@ class GrampsDbBase(GrampsDBCallback): attr_list = [] for mref in source.media_list: attr_list += [str(attr.type) for attr in mref.attribute_list - if attr.type.is_custom()] + if attr.type.is_custom() and str(attr.type)] self.media_attributes.update(attr_list) def commit_place(self, place, transaction, change_time=None): @@ -520,7 +520,7 @@ class GrampsDbBase(GrampsDBCallback): attr_list = [] for mref in place.media_list: attr_list += [str(attr.type) for attr in mref.attribute_list - if attr.type.is_custom()] + if attr.type.is_custom() and str(attr.type)] self.media_attributes.update(attr_list) def commit_personal_event(self, event, transaction, change_time=None): @@ -545,7 +545,7 @@ class GrampsDbBase(GrampsDBCallback): attr_list = [] for mref in event.media_list: attr_list += [str(attr.type) for attr in mref.attribute_list - if attr.type.is_custom()] + if attr.type.is_custom() and str(attr.type)] self.media_attributes.update(attr_list) def commit_family(self, family, transaction, change_time=None): @@ -560,7 +560,7 @@ class GrampsDbBase(GrampsDBCallback): self.family_attributes.update( [str(attr.type) for attr in family.attribute_list - if attr.type.is_custom()]) + if attr.type.is_custom() and str(attr.type)]) rel_list = [] for ref in family.child_ref_list: @@ -580,7 +580,7 @@ class GrampsDbBase(GrampsDBCallback): attr_list = [] for mref in family.media_list: attr_list += [str(attr.type) for attr in mref.attribute_list - if attr.type.is_custom()] + if attr.type.is_custom() and str(attr.type)] self.media_attributes.update(attr_list) def commit_repository(self, repository, transaction, change_time=None): diff --git a/src/ImgManip.py b/src/ImgManip.py index ee266cb57..9a80c5f87 100644 --- a/src/ImgManip.py +++ b/src/ImgManip.py @@ -116,7 +116,7 @@ def _build_thumb_path(path): return os.path.join(const.thumb_dir, m.hexdigest()+'.png') def run_thumbnailer(mtype, frm, to, size=const.thumbScale): - if const.use_thumbnailer: + if const.use_thumbnailer and os.path.isfile(frm): sublist = { '%s' : "%dx%d" % (int(size),int(size)), '%u' : frm,