Index: src/PhotoStore.cs =================================================================== RCS file: /cvs/gnome/f-spot/src/PhotoStore.cs,v retrieving revision 1.58 diff -u -r1.58 PhotoStore.cs --- src/PhotoStore.cs 20 Feb 2005 06:41:28 -0000 1.58 +++ src/PhotoStore.cs 23 Mar 2005 11:16:41 -0000 @@ -585,9 +585,14 @@ while (reader.Read ()) { uint tag_id = Convert.ToUInt32 (reader [0]); Tag tag = tag_store.Get (tag_id) as Tag; - photo.AddTagUnsafely (tag); + if(tag == null) { + Console.Error.WriteLine(String.Format( + "Photo {0} has invalid tag {1} in database", + photo.Path, tag_id)); + } + photo.AddTag (tag); } - + command.Dispose (); } @@ -644,10 +649,16 @@ continue; } - if (reader [1] != null) { + if (reader [1] != null) { uint tag_id = Convert.ToUInt32 (reader [1]); Tag tag = tag_store.Get (tag_id) as Tag; - photo.AddTagUnsafely (tag); + if(tag == null) { + Console.Error.WriteLine(String.Format( + "Photo {0} has invalid tag {1} in database", + photo.Path, tag_id)); + continue; + } + photo.AddTag (tag); } } } @@ -675,10 +686,16 @@ continue; } - if (reader [1] != null) { + if (reader [1] != null) { uint tag_id = Convert.ToUInt32 (reader [1]); Tag tag = tag_store.Get (tag_id) as Tag; - photo.AddTagUnsafely (tag); + if(tag == null) { + Console.Error.WriteLine(String.Format( + "Photo {0} has invalid tag {1} in database", + photo.Path, tag_id)); + } else { + photo.AddTag (tag); + } } if (reader [2] != null) { uint version_id = Convert.ToUInt32 (reader [2]); @@ -701,10 +718,16 @@ SqliteDataReader reader = command.ExecuteReader (); while (reader.Read ()) { - if (reader [0] != null) { + if (reader [0] != null) { uint tag_id = Convert.ToUInt32 (reader [0]); Tag tag = tag_store.Get (tag_id) as Tag; - photo.AddTagUnsafely (tag); + if(tag == null) { + Console.Error.WriteLine(String.Format( + "Photo {0} has invalid tag {1} in database", + photo.Path, tag_id)); + } else { + photo.AddTag (tag); + } } if (reader [1] != null) { uint version_id = Convert.ToUInt32 (reader [1]);