From b868e3e256b749a4f9d1ce4f15b4dddaf3602136 Mon Sep 17 00:00:00 2001 From: Josip Date: Sat, 8 Mar 2014 21:51:56 +0100 Subject: [PATCH] 7434: Media viewer list crashes during start if one try to select an entry where the media isn't available --- gramps/plugins/lib/libmetadata.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/gramps/plugins/lib/libmetadata.py b/gramps/plugins/lib/libmetadata.py index 46293aca3..943d307da 100644 --- a/gramps/plugins/lib/libmetadata.py +++ b/gramps/plugins/lib/libmetadata.py @@ -21,6 +21,13 @@ # # $Id$ # +#------------------------------------------------------------------------- +# +# Python modules +# +#------------------------------------------------------------------------- +import os + #------------------------------------------------------------------------- # # GNOME modules @@ -173,11 +180,14 @@ class MetadataView(Gtk.TreeView): self.sections = {} self.model.clear() - try: - metadata = GExiv2.Metadata(full_path) - except: + if os.path.exists(full_path): + try: + metadata = GExiv2.Metadata(full_path) + except: + return False + else: return False - + get_human = metadata.get_tag_interpreted_string for section, key, key2, func in TAGS: @@ -221,9 +231,12 @@ class MetadataView(Gtk.TreeView): """ Return True if the gramplet has data, else return False. """ - try: - metadata = GExiv2.Metadata(full_path) - except: + if os.path.exists(full_path): + try: + metadata = GExiv2.Metadata(full_path) + except: + return False + else: return False for tag in TAGS: